Skip to main content
8 events
when toggle format what by license comment
Aug 15, 2019 at 14:47 comment added Hi-Angel Oh, sorry, I might have screwed something, indeed works for me!
Aug 15, 2019 at 14:44 comment added manatwork @Hi-Angel, are you sure you used @ as array subscript? I gave it a test with zsh 5.5.1 and the only difference I noticed what zsh only prefixed each item when written as ${my_array[@]/#/-}, while bash did it for * subscript too.
Aug 15, 2019 at 14:19 comment added Hi-Angel Odd enough, doesn't work with zsh. The first time I stumbled upon something that works in bash but not zsh.
Feb 13, 2019 at 9:32 comment added manatwork @KonradRudolph, you can assign it to other variable as long as you do it as array assignment: somevar=("${my_array[@]/#/-}") (Note the parenthesis around the value.) Then of course you have to keep handling it as array when using it: echo "${somevar[@]}". Regarding the functions, there you are too limited by the language's possibilities. You can pass an array: somefunc "${my_array[@]/#/-}", then inside you will have it in $@: function somefunc() { echo "$@"; }. But same $@ will contain the other parameters too, if exists, and no other way to return the modified array than stdout.
Feb 12, 2019 at 19:00 comment added Konrad Rudolph If I understand correctly, this variable substitution can’t be wrapped into a function, nor be assigned to a variable, right? It needs to go directly into the command invocation.
Jan 23, 2012 at 4:50 vote accept Somebody still uses you MS-DOS
Jan 20, 2012 at 12:55 history edited manatwork CC BY-SA 3.0
corrected minor grammar
Jan 20, 2012 at 7:53 history answered manatwork CC BY-SA 3.0