Skip to content

Commit c530c4e

Browse files
authored
Fix process substitution is not POSIX-compliant (#2608)
1 parent 314a1cb commit c530c4e

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

sndev

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,11 @@ sndev__start() {
5656
}
5757

5858
sndev__dmenu_profile() {
59-
# dmenu allows to select multiple profiles with CTRL+Enter
60-
# in which case it will immediately write the selected profile to stdout
61-
# so we loop over each line of the output and add each profile to an array
62-
# to make sure we don't add duplicates
59+
# dmenu allows to select multiple profiles with CTRL+Enter in which case it will
60+
# immediately write the selected profile to stdout even if it was already selected
61+
# so we use sort+uniq to remove duplicates
6362
profiles="minimal payments wallets email search images capture"
64-
selected=()
65-
while read -r sel; do
66-
if [[ ! " ${selected[*]} " =~ " ${sel} " ]]; then
67-
selected+=("$sel")
68-
fi
69-
done < <(echo "$profiles" | tr ' ' '\n' | dmenu)
70-
printf '%s,' "${selected[@]}" | sed 's/,$//'
63+
echo "$profiles" | tr ' ' '\n' | dmenu | sort | uniq | tr '\n' ',' | sed 's/,$//'
7164
}
7265

7366
sndev__help_start() {

0 commit comments

Comments
 (0)