Created
April 26, 2012 12:15
-
-
Save mjf/2499208 to your computer and use it in GitHub Desktop.
Script to tell whether any of it's argument repeats
This file contains hidden or 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 | |
# If no arguments are given, return true. | |
if [ $# -eq 0 ] | |
then | |
exit 0 | |
fi | |
# Test whether any of the arguments repeats. | |
while [ $# -gt 0 ] | |
do | |
_CURRENT="$1" | |
shift | |
for _ITEM in "$@" | |
do | |
if [ "$_CURRENT" = "$_ITEM" ] | |
then | |
exit 0 | |
fi | |
done | |
done | |
# If not, return false. | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment