Skip to main content
7 events
when toggle format what by license comment
Apr 13, 2017 at 12:36 history edited CommunityBot
replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
Dec 10, 2014 at 11:55 history edited garethTheRed CC BY-SA 3.0
Added link to QA on quoting shell variables
Dec 10, 2014 at 11:51 comment added garethTheRed @StéphaneChazelas - fair point. That'll teach me to try and argue... In my defence, I my answer was only commenting on the original code - I didn't write it.
Dec 10, 2014 at 11:42 comment added Stéphane Chazelas That's still invoking the split+glob operator which doesn't make sense. And it returns 30 unless IFS contains 3 or 0. For instance, if it's 0, that becomes awk -vbenchmark=3 '' '{thecode}' the files. The code becomes '' (which with most awk implementations make awk return immediately without an error); if it's 3, that becomes awk -vbenchmark= 0 '{the-code}' which will treat {the-code} as a file will cause awk to read that and the other files but output nothing as the code is now 0.
Dec 10, 2014 at 11:30 comment added garethTheRed @StéphaneChazelas - but the original author got away with it in this instance as a split & glob of 30 returns 30. Obviously he/she hadn't read your excellent QA on the subject :-)
Dec 10, 2014 at 11:12 comment added Stéphane Chazelas That's -vbenchmark="$benchmark" to assign the value of the shell variable (after expanding the \x sequences in it) to the awk variable. -vbenchmark=$benchmark without the quotes doesn't make any sense as that's invoking the shell's split+glob operator.
Dec 10, 2014 at 11:01 history answered garethTheRed CC BY-SA 3.0