Created
March 7, 2018 13:13
-
-
Save alganet/4616521d43e8386e6c837e6d02576716 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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