Skip to content

Instantly share code, notes, and snippets.

@pandorasNox
Created October 10, 2017 00:41
Show Gist options
  • Save pandorasNox/63ae4c27f79cda4c77561bce7e4e9b09 to your computer and use it in GitHub Desktop.
Save pandorasNox/63ae4c27f79cda4c77561bce7e4e9b09 to your computer and use it in GitHub Desktop.
iterate over sh arguments and concat them (sh !!! not bash)
#!/bin/sh
# exit code
E_BADARGS=85
ARG_LIST=""
index=0 # Reset count.
for arg in "$@"
do
#skipp first argument
if [ "$index" -eq "0" ]; then
let "index+=1"
continue
fi
if [ "$index" -eq "1" ]; then
ARG_LIST=$ARG_LIST$arg
let "index+=1"
continue
fi
ARG_LIST=$ARG_LIST" "$arg
let "index+=1"
done
echo "ARG_LIST"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment