Skip to content

Instantly share code, notes, and snippets.

@alganet
Created March 7, 2018 13:13
Show Gist options
  • Save alganet/4616521d43e8386e6c837e6d02576716 to your computer and use it in GitHub Desktop.
Save alganet/4616521d43e8386e6c837e6d02576716 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Before
set 1 2 3 4 5
while test $# -gt 0;do
echo $1
shift
done
# After
set 1 2 3 4 5
while test "${#}" -gt 0
do
echo "${1}"
shift
done
# - Always quote variables! They will look more visible and be more secure.
# - No need for ;do on the same line as while...
#
# Thanks!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment