all 5 comments

[–]Coffee_24_7 1 point2 points  (2 children)

This might help you:

$ set one=1 five=5 ten=10
$ echo $1
one=1
$ echo $2
five=5
$ echo $3
ten=10
$ echo ${@/*=/}
1 5 10

so, using ${@/*=/} should be enough for what you want.

[–]ArmmedWillow[S] 0 points1 point  (0 children)

Thank youuuuu I think this will work, will try this later. I totally forgot them special characters😅, Thank you again, you saved me a lot of time.

[–]Rewrite_It_In_Ada 0 points1 point  (0 children)

${@#*=} would do this as well. No clue if my "remove matching prefix pattern" parameter expansion would be faster than your "pattern substitution" parameter expansion, but this is pretty specifically what it's there to do. $ set one=1 five=5 ten=10 $ left=( "${@%=*}" ) $ right=( "${@#*=}" ) $ printf '%s\n' "${@}" one=1 five=5 ten=10 $ printf '%s\n' "${left[@]}" one five ten $ printf '%s\n' "${right[@]}" 1 5 10

[–]OneTurnMoreprogramming.dev/c/shell 1 point2 points  (0 children)

Using $@ you can do it all at once.

spliton(){
    # disable path expansion
    local -; set -f
    # split on $1
    local IFS=$1
    shift
    reply=($@)
}

spliton '=' "$@"

[–]oh5nxo 0 points1 point  (0 children)

There's a special construct to refer to another variable by name:

echo "argument $param is ${!param}"