Penguin
Diff: SpacesInPathNames
EditPageHistoryDiffInfoLikePages

Differences between version 3 and predecessor to the previous major change of SpacesInPathNames.

Other diffs: Previous Revision, Previous Author, or view the Annotated Edit History

Newer page: version 3 Last edited on Tuesday, March 21, 2006 8:09:38 pm by JohnMcPherson Revert
Older page: version 2 Last edited on Tuesday, March 21, 2006 7:53:31 pm by LawrenceDoliveiro Revert
@@ -14,4 +14,30 @@
  
  <pre> 
  find Events -name data.txt -print0 | xargs -0 -L1 wc -l 
  </pre> 
+  
+----  
+As discussed on the BashNotes page, scripts can cope with arguments that contain spaces if you are careful. <tt>bash</tt> will expand *$@* as all of its arguments, but importantly will expand *"$@"* as each argument surrounded by "quote marks". Eg, if a script is called with arguments  
+<verbatim>  
+ ./myscript "argument 1" "argument 2"  
+</verbatim>  
+then a script that did  
+<verbatim>  
+ perl -e 'foreach $a (@ARGV) {print ".$a.\n"}' $@  
+</verbatim>  
+would output  
+<verbatim>  
+.argument.  
+.1.  
+.argument.  
+.2.  
+</verbatim>  
+while a script that did  
+<verbatim>  
+ perl -e 'foreach $a (@ARGV) {print ".$a.\n"}' "$@"  
+</verbatim>  
+would output  
+<verbatim>  
+.argument 1.  
+.argument 2.  
+</verbatim>