@derobert Both the R and Common Lisp REPLs echo 1, FWIW.
For a scripting language, I'd say it's quite common behavior. But no doubt my ignorance of programming languages lulled me into a false sense of uniformity.
@MichaelHomer I was just referring to the sentence "Arch Linux follows the file system hierarchy for operating systems using the systemd service manager".
Someone at work spotted the following pipeline in a bioinformatics-related forum: ls *.gz | awk '{print "gunzip " $0}' | bash
Never write code like that!
It's a case of "I know I can do this with that command, and that with this command", but not knowing how to properly combine them, or when it's apropriate to do so.
A few years ago I had some in front of me and it had the most enormous command substitution in the middle, and all it did was unconditionally output "0" after a chain of several awks and greps. But presumably at some point all the bits made sense
I really feel that a slightly more practical software carpentry-type training would be a huge help
@MichaelHomer We do have both Unix and Python training for our bioinformatics students and Ph.D. students (and post-docs, and other staff) here, and part of my work is to make sure that the people that teach those classes know what they are talking about.
The issue is that when you're taught that you "get a list of files with ls", then this will be how you get a list of files, in loops, in pipelines and everywhere else.
@overexchange The script was written with a function called main that essentially does all the execution
Within the script that function is being called with all the arguments that were passed to the script
$@ represents all the script parameters so if you called it as: ./script.sh foo bar baz it will essentially be calling main foo bar baz. Inside main $1 = foo, $2 = bar, and $3 = baz
Consider the following code:
foo () {
echo $*
}
bar () {
echo $@
}
foo 1 2 3 4
bar 1 2 3 4
It outputs:
1 2 3 4
1 2 3 4
I am using Ksh88, but I am interested in other common shells as well. If you happen to know any particularity for specific shells, please do mention them...