I was trying to learn and write some fish scripts, but I encountered a strange issue.
# a.fish # this is a fish script set temp (getopt -o abc -l ace,bad,correct -- $argv) echo $temp
When I ran
fish ./a.fish -a -b --correct it worked fine and output
-a -b --correct --
Then I wrote a bash script
# a.sh temp=$(getopt -o abc -l ace,bad,correct -- $@) echo $temp
and ran it with
bash ./a.sh -a -b --correct. Worked fine. After I added
$@ it still worked fine!
So here comes the question:
What's the difference between
$@ (or maybe I should ask whether fish and bash handle variables differently?)
I thought it was just simple replacement but this confused me. Can somebody help me? Any help will be appreciated :)
OS: ubuntu 16.04