[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 80db1412cd2c8f42cc38cff4851b05998d2d5a7e

Ville Skyttä ville.skytta at iki.fi
Tue Apr 14 18:38:07 UTC 2009


The following commit has been merged in the master branch:
commit 80db1412cd2c8f42cc38cff4851b05998d2d5a7e
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Tue Apr 14 21:38:03 2009 +0300

    Add note about compgen -- $cur vs embedding $cur in external command arguments.

diff --git a/README b/README
index c403179..7cfd1bd 100644
--- a/README
+++ b/README
@@ -450,6 +450,16 @@ guidelines in mind:
   These forms of parameter substitutions can also be used on arrays,
   which makes them very powerful (if a little slow).
 
+- Prefer "compgen -W '...' -- $cur" over embedding $cur in external
+  command arguments (often e.g. sed, grep etc) unless there's a good
+  reason to embed it.  Embedding user input in command lines can
+  result in syntax errors and other undesired behavior, or messy
+  quoting requirements when the input contains unusual characters.
+  Good reasons for embedding include functionality (if the thing
+  does not sanely work otherwise) or performance (if it makes a big
+  difference in speed), but all embedding cases should be documented
+  with rationale in comments in the code.
+
 - Do not write to the file-system under any circumstances. This can
   create race conditions, is inefficient, violates the principle of
   least surprise and lacks robustness.

-- 
bash-completion



More information about the Bash-completion-commits mailing list