Using case and arrays together in bash
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
Is it possible to check if a variable is contained inside an array using case
? I would like to do something like
ARR=( opt1 opt2 opt3 );
case $1 in
$ARR)
echo "Option is contained in the array";
*)
echo "Option is not contained in the array";
esac
bash shell-script scripting array case
add a comment |Â
up vote
2
down vote
favorite
Is it possible to check if a variable is contained inside an array using case
? I would like to do something like
ARR=( opt1 opt2 opt3 );
case $1 in
$ARR)
echo "Option is contained in the array";
*)
echo "Option is not contained in the array";
esac
bash shell-script scripting array case
1
Are you mandated to usecase
?
â Inian
Dec 15 '17 at 8:57
Possible duplicate of How do I test if an item is in a bash array?
â muru
Dec 15 '17 at 12:21
@muru, I'd say it's different here because of thecase
requirement. Presumably in the end the OP wants to add more cases as incase $1 in $ARR1)... $ARR2)... foo) bar)...; esac
â Stéphane Chazelas
Dec 15 '17 at 13:10
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
Is it possible to check if a variable is contained inside an array using case
? I would like to do something like
ARR=( opt1 opt2 opt3 );
case $1 in
$ARR)
echo "Option is contained in the array";
*)
echo "Option is not contained in the array";
esac
bash shell-script scripting array case
Is it possible to check if a variable is contained inside an array using case
? I would like to do something like
ARR=( opt1 opt2 opt3 );
case $1 in
$ARR)
echo "Option is contained in the array";
*)
echo "Option is not contained in the array";
esac
bash shell-script scripting array case
edited Dec 19 '17 at 1:31
Jeff Schaller
31.9k848109
31.9k848109
asked Dec 15 '17 at 8:46
red_trumpet
1567
1567
1
Are you mandated to usecase
?
â Inian
Dec 15 '17 at 8:57
Possible duplicate of How do I test if an item is in a bash array?
â muru
Dec 15 '17 at 12:21
@muru, I'd say it's different here because of thecase
requirement. Presumably in the end the OP wants to add more cases as incase $1 in $ARR1)... $ARR2)... foo) bar)...; esac
â Stéphane Chazelas
Dec 15 '17 at 13:10
add a comment |Â
1
Are you mandated to usecase
?
â Inian
Dec 15 '17 at 8:57
Possible duplicate of How do I test if an item is in a bash array?
â muru
Dec 15 '17 at 12:21
@muru, I'd say it's different here because of thecase
requirement. Presumably in the end the OP wants to add more cases as incase $1 in $ARR1)... $ARR2)... foo) bar)...; esac
â Stéphane Chazelas
Dec 15 '17 at 13:10
1
1
Are you mandated to use
case
?â Inian
Dec 15 '17 at 8:57
Are you mandated to use
case
?â Inian
Dec 15 '17 at 8:57
Possible duplicate of How do I test if an item is in a bash array?
â muru
Dec 15 '17 at 12:21
Possible duplicate of How do I test if an item is in a bash array?
â muru
Dec 15 '17 at 12:21
@muru, I'd say it's different here because of the
case
requirement. Presumably in the end the OP wants to add more cases as in case $1 in $ARR1)... $ARR2)... foo) bar)...; esac
â Stéphane Chazelas
Dec 15 '17 at 13:10
@muru, I'd say it's different here because of the
case
requirement. Presumably in the end the OP wants to add more cases as in case $1 in $ARR1)... $ARR2)... foo) bar)...; esac
â Stéphane Chazelas
Dec 15 '17 at 13:10
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
4
down vote
With ksh93
, thanks to this bug, you can do:
IFS='|'
ARR=( opt1 opt2 opt3 )
IFS='|'
case $1 in
(@("$ARR[*]"))
echo "Option is contained in the array";;
(*)
echo "Option is not contained in the array";;
esac
(I wouldn't rely on it as the bug might get fixed in the future).
With zsh
, you could do:
case $ARR[(Ie)$1]
(0)
echo "Option is not contained in the array";;
(*)
echo "Option is contained in the array";;
esac
(though, you'd probably rather want to use if ((ARR[(Ie)$1])); then echo is present...
here rather than a case construct).
$array[(I)pattern]
returns the index of the last element that matches the pattern in the array, or 0 otherwise. The e
flag is for exact match (as opposed to pattern match).
With bash
, ksh
, yash
, zsh
, if you're ready to assume that $ARR
and $1
don't contain a certain character like @
, and that $ARR
won't be empty, you can do:
IFS=@
case "@$ARR[*]@" in
(*"@$1@"*)
echo "Option is contained in the array";;
(*)
echo "Option is not contained in the array";;
esac
With bash -O extglob
, zsh -o kshglob -o globsubst
, you could define a helper that builds a pattern based on the elements of the array:
arraypat()
awk '
BEGIN
if (ARGC <= 1) print "!(*)"
else
for (i = 1; i < ARGC; i++)
gsub(/[
print "@(" s ")"
' "$@"
case $1 in
($(arraypat "$ARR[@]"))
echo "Option is contained in the array";;
(*)
echo "Option is not contained in the array";;
esac
@glennjackman, oops. Thanks. Well spotted.
â Stéphane Chazelas
Dec 15 '17 at 11:03
add a comment |Â
up vote
3
down vote
Not really in a compact and easy to use way. Remember that $ARR
will expand to only the first element of the array, opt1
in your example.
You could use "$ARR[@]"
, but using your data this would give a false positive for the string 1 opt
.
With more recent versions of bash
, you could consider using an associative array:
declare -A arr
arr=( [opt1]=1 [opt2]=1 [opt3]=1 )
if [[ "$arr[$1]" -eq 1 ]]; then
# $1 is a key in arr
else
# is not
fi
Or to get full use of the associative array, i.e. use arbitrary values, not just1
, test with something like[[ "$arr[$1]+x" ]]
(it's shorter, too!)
â ilkkachu
Dec 15 '17 at 10:44
@ilkkachu Yes, or[[ -n "$arr[$1]" ]]
.
â Kusalananda
Dec 15 '17 at 10:49
add a comment |Â
up vote
2
down vote
Why would you want to do it with case
? It's meant for string pattern matching, not per-element matching.
Frankly, if you need the "contains" test often and want to make it short because of that, just put the hard part in a function instead of using ugly workarounds:
#!/bin/bash
ARR=( foo bar doo );
contains()
typeset _x;
typeset -n _A="$1"
for _x in "$_A[@]" ; do
[ "$_x" = "$2" ] && return 0
done
return 1
if contains ARR "$1" ; then
echo ""$1" is contained in ARR"
else
echo ""$1" not contained in ARR"
fi
(That should also work in ksh
)
OP probably wants a builtin for the presumed speed and efficiency.
â RonJohn
Dec 15 '17 at 13:26
@RonJohn, everything that function does, is built in to Bash. As for speed, it's hard to say, we'd need to test, but for huge data sets, associative arrays would probably be faster (than either the loop, or acase
), since key lookups are presumably O(1). But for huge data, you shouldn't use the shell anyway, and for small data, minor performance differences don't matter.
â ilkkachu
Dec 15 '17 at 14:04
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
With ksh93
, thanks to this bug, you can do:
IFS='|'
ARR=( opt1 opt2 opt3 )
IFS='|'
case $1 in
(@("$ARR[*]"))
echo "Option is contained in the array";;
(*)
echo "Option is not contained in the array";;
esac
(I wouldn't rely on it as the bug might get fixed in the future).
With zsh
, you could do:
case $ARR[(Ie)$1]
(0)
echo "Option is not contained in the array";;
(*)
echo "Option is contained in the array";;
esac
(though, you'd probably rather want to use if ((ARR[(Ie)$1])); then echo is present...
here rather than a case construct).
$array[(I)pattern]
returns the index of the last element that matches the pattern in the array, or 0 otherwise. The e
flag is for exact match (as opposed to pattern match).
With bash
, ksh
, yash
, zsh
, if you're ready to assume that $ARR
and $1
don't contain a certain character like @
, and that $ARR
won't be empty, you can do:
IFS=@
case "@$ARR[*]@" in
(*"@$1@"*)
echo "Option is contained in the array";;
(*)
echo "Option is not contained in the array";;
esac
With bash -O extglob
, zsh -o kshglob -o globsubst
, you could define a helper that builds a pattern based on the elements of the array:
arraypat()
awk '
BEGIN
if (ARGC <= 1) print "!(*)"
else
for (i = 1; i < ARGC; i++)
gsub(/[
print "@(" s ")"
' "$@"
case $1 in
($(arraypat "$ARR[@]"))
echo "Option is contained in the array";;
(*)
echo "Option is not contained in the array";;
esac
@glennjackman, oops. Thanks. Well spotted.
â Stéphane Chazelas
Dec 15 '17 at 11:03
add a comment |Â
up vote
4
down vote
With ksh93
, thanks to this bug, you can do:
IFS='|'
ARR=( opt1 opt2 opt3 )
IFS='|'
case $1 in
(@("$ARR[*]"))
echo "Option is contained in the array";;
(*)
echo "Option is not contained in the array";;
esac
(I wouldn't rely on it as the bug might get fixed in the future).
With zsh
, you could do:
case $ARR[(Ie)$1]
(0)
echo "Option is not contained in the array";;
(*)
echo "Option is contained in the array";;
esac
(though, you'd probably rather want to use if ((ARR[(Ie)$1])); then echo is present...
here rather than a case construct).
$array[(I)pattern]
returns the index of the last element that matches the pattern in the array, or 0 otherwise. The e
flag is for exact match (as opposed to pattern match).
With bash
, ksh
, yash
, zsh
, if you're ready to assume that $ARR
and $1
don't contain a certain character like @
, and that $ARR
won't be empty, you can do:
IFS=@
case "@$ARR[*]@" in
(*"@$1@"*)
echo "Option is contained in the array";;
(*)
echo "Option is not contained in the array";;
esac
With bash -O extglob
, zsh -o kshglob -o globsubst
, you could define a helper that builds a pattern based on the elements of the array:
arraypat()
awk '
BEGIN
if (ARGC <= 1) print "!(*)"
else
for (i = 1; i < ARGC; i++)
gsub(/[
print "@(" s ")"
' "$@"
case $1 in
($(arraypat "$ARR[@]"))
echo "Option is contained in the array";;
(*)
echo "Option is not contained in the array";;
esac
@glennjackman, oops. Thanks. Well spotted.
â Stéphane Chazelas
Dec 15 '17 at 11:03
add a comment |Â
up vote
4
down vote
up vote
4
down vote
With ksh93
, thanks to this bug, you can do:
IFS='|'
ARR=( opt1 opt2 opt3 )
IFS='|'
case $1 in
(@("$ARR[*]"))
echo "Option is contained in the array";;
(*)
echo "Option is not contained in the array";;
esac
(I wouldn't rely on it as the bug might get fixed in the future).
With zsh
, you could do:
case $ARR[(Ie)$1]
(0)
echo "Option is not contained in the array";;
(*)
echo "Option is contained in the array";;
esac
(though, you'd probably rather want to use if ((ARR[(Ie)$1])); then echo is present...
here rather than a case construct).
$array[(I)pattern]
returns the index of the last element that matches the pattern in the array, or 0 otherwise. The e
flag is for exact match (as opposed to pattern match).
With bash
, ksh
, yash
, zsh
, if you're ready to assume that $ARR
and $1
don't contain a certain character like @
, and that $ARR
won't be empty, you can do:
IFS=@
case "@$ARR[*]@" in
(*"@$1@"*)
echo "Option is contained in the array";;
(*)
echo "Option is not contained in the array";;
esac
With bash -O extglob
, zsh -o kshglob -o globsubst
, you could define a helper that builds a pattern based on the elements of the array:
arraypat()
awk '
BEGIN
if (ARGC <= 1) print "!(*)"
else
for (i = 1; i < ARGC; i++)
gsub(/[
print "@(" s ")"
' "$@"
case $1 in
($(arraypat "$ARR[@]"))
echo "Option is contained in the array";;
(*)
echo "Option is not contained in the array";;
esac
With ksh93
, thanks to this bug, you can do:
IFS='|'
ARR=( opt1 opt2 opt3 )
IFS='|'
case $1 in
(@("$ARR[*]"))
echo "Option is contained in the array";;
(*)
echo "Option is not contained in the array";;
esac
(I wouldn't rely on it as the bug might get fixed in the future).
With zsh
, you could do:
case $ARR[(Ie)$1]
(0)
echo "Option is not contained in the array";;
(*)
echo "Option is contained in the array";;
esac
(though, you'd probably rather want to use if ((ARR[(Ie)$1])); then echo is present...
here rather than a case construct).
$array[(I)pattern]
returns the index of the last element that matches the pattern in the array, or 0 otherwise. The e
flag is for exact match (as opposed to pattern match).
With bash
, ksh
, yash
, zsh
, if you're ready to assume that $ARR
and $1
don't contain a certain character like @
, and that $ARR
won't be empty, you can do:
IFS=@
case "@$ARR[*]@" in
(*"@$1@"*)
echo "Option is contained in the array";;
(*)
echo "Option is not contained in the array";;
esac
With bash -O extglob
, zsh -o kshglob -o globsubst
, you could define a helper that builds a pattern based on the elements of the array:
arraypat()
awk '
BEGIN
if (ARGC <= 1) print "!(*)"
else
for (i = 1; i < ARGC; i++)
gsub(/[
print "@(" s ")"
' "$@"
case $1 in
($(arraypat "$ARR[@]"))
echo "Option is contained in the array";;
(*)
echo "Option is not contained in the array";;
esac
edited Dec 15 '17 at 13:20
answered Dec 15 '17 at 9:30
Stéphane Chazelas
282k53520854
282k53520854
@glennjackman, oops. Thanks. Well spotted.
â Stéphane Chazelas
Dec 15 '17 at 11:03
add a comment |Â
@glennjackman, oops. Thanks. Well spotted.
â Stéphane Chazelas
Dec 15 '17 at 11:03
@glennjackman, oops. Thanks. Well spotted.
â Stéphane Chazelas
Dec 15 '17 at 11:03
@glennjackman, oops. Thanks. Well spotted.
â Stéphane Chazelas
Dec 15 '17 at 11:03
add a comment |Â
up vote
3
down vote
Not really in a compact and easy to use way. Remember that $ARR
will expand to only the first element of the array, opt1
in your example.
You could use "$ARR[@]"
, but using your data this would give a false positive for the string 1 opt
.
With more recent versions of bash
, you could consider using an associative array:
declare -A arr
arr=( [opt1]=1 [opt2]=1 [opt3]=1 )
if [[ "$arr[$1]" -eq 1 ]]; then
# $1 is a key in arr
else
# is not
fi
Or to get full use of the associative array, i.e. use arbitrary values, not just1
, test with something like[[ "$arr[$1]+x" ]]
(it's shorter, too!)
â ilkkachu
Dec 15 '17 at 10:44
@ilkkachu Yes, or[[ -n "$arr[$1]" ]]
.
â Kusalananda
Dec 15 '17 at 10:49
add a comment |Â
up vote
3
down vote
Not really in a compact and easy to use way. Remember that $ARR
will expand to only the first element of the array, opt1
in your example.
You could use "$ARR[@]"
, but using your data this would give a false positive for the string 1 opt
.
With more recent versions of bash
, you could consider using an associative array:
declare -A arr
arr=( [opt1]=1 [opt2]=1 [opt3]=1 )
if [[ "$arr[$1]" -eq 1 ]]; then
# $1 is a key in arr
else
# is not
fi
Or to get full use of the associative array, i.e. use arbitrary values, not just1
, test with something like[[ "$arr[$1]+x" ]]
(it's shorter, too!)
â ilkkachu
Dec 15 '17 at 10:44
@ilkkachu Yes, or[[ -n "$arr[$1]" ]]
.
â Kusalananda
Dec 15 '17 at 10:49
add a comment |Â
up vote
3
down vote
up vote
3
down vote
Not really in a compact and easy to use way. Remember that $ARR
will expand to only the first element of the array, opt1
in your example.
You could use "$ARR[@]"
, but using your data this would give a false positive for the string 1 opt
.
With more recent versions of bash
, you could consider using an associative array:
declare -A arr
arr=( [opt1]=1 [opt2]=1 [opt3]=1 )
if [[ "$arr[$1]" -eq 1 ]]; then
# $1 is a key in arr
else
# is not
fi
Not really in a compact and easy to use way. Remember that $ARR
will expand to only the first element of the array, opt1
in your example.
You could use "$ARR[@]"
, but using your data this would give a false positive for the string 1 opt
.
With more recent versions of bash
, you could consider using an associative array:
declare -A arr
arr=( [opt1]=1 [opt2]=1 [opt3]=1 )
if [[ "$arr[$1]" -eq 1 ]]; then
# $1 is a key in arr
else
# is not
fi
edited May 5 at 21:22
answered Dec 15 '17 at 8:59
Kusalananda
104k14206324
104k14206324
Or to get full use of the associative array, i.e. use arbitrary values, not just1
, test with something like[[ "$arr[$1]+x" ]]
(it's shorter, too!)
â ilkkachu
Dec 15 '17 at 10:44
@ilkkachu Yes, or[[ -n "$arr[$1]" ]]
.
â Kusalananda
Dec 15 '17 at 10:49
add a comment |Â
Or to get full use of the associative array, i.e. use arbitrary values, not just1
, test with something like[[ "$arr[$1]+x" ]]
(it's shorter, too!)
â ilkkachu
Dec 15 '17 at 10:44
@ilkkachu Yes, or[[ -n "$arr[$1]" ]]
.
â Kusalananda
Dec 15 '17 at 10:49
Or to get full use of the associative array, i.e. use arbitrary values, not just
1
, test with something like [[ "$arr[$1]+x" ]]
(it's shorter, too!)â ilkkachu
Dec 15 '17 at 10:44
Or to get full use of the associative array, i.e. use arbitrary values, not just
1
, test with something like [[ "$arr[$1]+x" ]]
(it's shorter, too!)â ilkkachu
Dec 15 '17 at 10:44
@ilkkachu Yes, or
[[ -n "$arr[$1]" ]]
.â Kusalananda
Dec 15 '17 at 10:49
@ilkkachu Yes, or
[[ -n "$arr[$1]" ]]
.â Kusalananda
Dec 15 '17 at 10:49
add a comment |Â
up vote
2
down vote
Why would you want to do it with case
? It's meant for string pattern matching, not per-element matching.
Frankly, if you need the "contains" test often and want to make it short because of that, just put the hard part in a function instead of using ugly workarounds:
#!/bin/bash
ARR=( foo bar doo );
contains()
typeset _x;
typeset -n _A="$1"
for _x in "$_A[@]" ; do
[ "$_x" = "$2" ] && return 0
done
return 1
if contains ARR "$1" ; then
echo ""$1" is contained in ARR"
else
echo ""$1" not contained in ARR"
fi
(That should also work in ksh
)
OP probably wants a builtin for the presumed speed and efficiency.
â RonJohn
Dec 15 '17 at 13:26
@RonJohn, everything that function does, is built in to Bash. As for speed, it's hard to say, we'd need to test, but for huge data sets, associative arrays would probably be faster (than either the loop, or acase
), since key lookups are presumably O(1). But for huge data, you shouldn't use the shell anyway, and for small data, minor performance differences don't matter.
â ilkkachu
Dec 15 '17 at 14:04
add a comment |Â
up vote
2
down vote
Why would you want to do it with case
? It's meant for string pattern matching, not per-element matching.
Frankly, if you need the "contains" test often and want to make it short because of that, just put the hard part in a function instead of using ugly workarounds:
#!/bin/bash
ARR=( foo bar doo );
contains()
typeset _x;
typeset -n _A="$1"
for _x in "$_A[@]" ; do
[ "$_x" = "$2" ] && return 0
done
return 1
if contains ARR "$1" ; then
echo ""$1" is contained in ARR"
else
echo ""$1" not contained in ARR"
fi
(That should also work in ksh
)
OP probably wants a builtin for the presumed speed and efficiency.
â RonJohn
Dec 15 '17 at 13:26
@RonJohn, everything that function does, is built in to Bash. As for speed, it's hard to say, we'd need to test, but for huge data sets, associative arrays would probably be faster (than either the loop, or acase
), since key lookups are presumably O(1). But for huge data, you shouldn't use the shell anyway, and for small data, minor performance differences don't matter.
â ilkkachu
Dec 15 '17 at 14:04
add a comment |Â
up vote
2
down vote
up vote
2
down vote
Why would you want to do it with case
? It's meant for string pattern matching, not per-element matching.
Frankly, if you need the "contains" test often and want to make it short because of that, just put the hard part in a function instead of using ugly workarounds:
#!/bin/bash
ARR=( foo bar doo );
contains()
typeset _x;
typeset -n _A="$1"
for _x in "$_A[@]" ; do
[ "$_x" = "$2" ] && return 0
done
return 1
if contains ARR "$1" ; then
echo ""$1" is contained in ARR"
else
echo ""$1" not contained in ARR"
fi
(That should also work in ksh
)
Why would you want to do it with case
? It's meant for string pattern matching, not per-element matching.
Frankly, if you need the "contains" test often and want to make it short because of that, just put the hard part in a function instead of using ugly workarounds:
#!/bin/bash
ARR=( foo bar doo );
contains()
typeset _x;
typeset -n _A="$1"
for _x in "$_A[@]" ; do
[ "$_x" = "$2" ] && return 0
done
return 1
if contains ARR "$1" ; then
echo ""$1" is contained in ARR"
else
echo ""$1" not contained in ARR"
fi
(That should also work in ksh
)
edited Dec 15 '17 at 11:16
answered Dec 15 '17 at 10:49
ilkkachu
49.9k674137
49.9k674137
OP probably wants a builtin for the presumed speed and efficiency.
â RonJohn
Dec 15 '17 at 13:26
@RonJohn, everything that function does, is built in to Bash. As for speed, it's hard to say, we'd need to test, but for huge data sets, associative arrays would probably be faster (than either the loop, or acase
), since key lookups are presumably O(1). But for huge data, you shouldn't use the shell anyway, and for small data, minor performance differences don't matter.
â ilkkachu
Dec 15 '17 at 14:04
add a comment |Â
OP probably wants a builtin for the presumed speed and efficiency.
â RonJohn
Dec 15 '17 at 13:26
@RonJohn, everything that function does, is built in to Bash. As for speed, it's hard to say, we'd need to test, but for huge data sets, associative arrays would probably be faster (than either the loop, or acase
), since key lookups are presumably O(1). But for huge data, you shouldn't use the shell anyway, and for small data, minor performance differences don't matter.
â ilkkachu
Dec 15 '17 at 14:04
OP probably wants a builtin for the presumed speed and efficiency.
â RonJohn
Dec 15 '17 at 13:26
OP probably wants a builtin for the presumed speed and efficiency.
â RonJohn
Dec 15 '17 at 13:26
@RonJohn, everything that function does, is built in to Bash. As for speed, it's hard to say, we'd need to test, but for huge data sets, associative arrays would probably be faster (than either the loop, or a
case
), since key lookups are presumably O(1). But for huge data, you shouldn't use the shell anyway, and for small data, minor performance differences don't matter.â ilkkachu
Dec 15 '17 at 14:04
@RonJohn, everything that function does, is built in to Bash. As for speed, it's hard to say, we'd need to test, but for huge data sets, associative arrays would probably be faster (than either the loop, or a
case
), since key lookups are presumably O(1). But for huge data, you shouldn't use the shell anyway, and for small data, minor performance differences don't matter.â ilkkachu
Dec 15 '17 at 14:04
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f411001%2fusing-case-and-arrays-together-in-bash%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
Are you mandated to use
case
?â Inian
Dec 15 '17 at 8:57
Possible duplicate of How do I test if an item is in a bash array?
â muru
Dec 15 '17 at 12:21
@muru, I'd say it's different here because of the
case
requirement. Presumably in the end the OP wants to add more cases as incase $1 in $ARR1)... $ARR2)... foo) bar)...; esac
â Stéphane Chazelas
Dec 15 '17 at 13:10