benlangmuir created this revision.
benlangmuir added reviewers: yamaguchi, v.g.vassilev, ruiu, teemperor.
Herald added a subscriber: cfe-commits.

We have a regex that needs to match a tab character in the command output, but 
on macOS `sed` doesn't support '\t', causing it to split on the 't' character 
instead. Some options:

- use `perl -p -e 's/\t.*//'`, which does handle '\t'
- put a literal tab character in the string passed to sed
- use `sed -e $'s/\t.*//'`, which will cause bash to expand the '\t' before 
passing it to sed


Repository:
  rC Clang

https://reviews.llvm.org/D47273

Files:
  utils/bash-autocomplete.sh


Index: utils/bash-autocomplete.sh
===================================================================
--- utils/bash-autocomplete.sh
+++ utils/bash-autocomplete.sh
@@ -38,7 +38,7 @@
 
   # expand ~ to $HOME
   eval local path=${COMP_WORDS[0]}
-  flags=$( "$path" --autocomplete="$arg" 2>/dev/null | sed -e 's/\t.*//' )
+  flags=$( "$path" --autocomplete="$arg" 2>/dev/null | perl -p -e 's/\t.*//' )
   # If clang is old that it does not support --autocomplete,
   # fall back to the filename completion.
   if [[ "$?" != 0 ]]; then


Index: utils/bash-autocomplete.sh
===================================================================
--- utils/bash-autocomplete.sh
+++ utils/bash-autocomplete.sh
@@ -38,7 +38,7 @@
 
   # expand ~ to $HOME
   eval local path=${COMP_WORDS[0]}
-  flags=$( "$path" --autocomplete="$arg" 2>/dev/null | sed -e 's/\t.*//' )
+  flags=$( "$path" --autocomplete="$arg" 2>/dev/null | perl -p -e 's/\t.*//' )
   # If clang is old that it does not support --autocomplete,
   # fall back to the filename completion.
   if [[ "$?" != 0 ]]; then
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to