[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
select syntax violates the POLA
From: |
greywolf |
Subject: |
select syntax violates the POLA |
Date: |
Thu, 1 Apr 2021 01:36:59 -0700 (PDT) |
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: netbsd
Compiler: gcc
Compilation CFLAGS: -O2 -I/usr/local/include -D_FORTIFY_SOURCE=2 -I/usr/include
uname output: NetBSD eddie.starwolf.com 9.99.81 NetBSD 9.99.81 (EDDIE) #9: Tue
Mar 23 19:13:25 PDT 2021 greywolf@eddie.starwolf.com:/sys/native/compile/EDDIE
amd64
Machine Type: x86_64--netbsd
Bash Version: 5.1
Patch Level: 4
Release Status: release
Description:
The 'select' directive's syntax does not correspond to the rest of the
shell's syntax.
I am not sure if this is by design; if it is, let me know and I'll go
away.
The following is valid shell code:
d=($(ls /usr/src/pkg/*/$1));
n=${#d[@]};
if ((n > 1)); then {
echo "Ambiguous dir specification";
exit 1;
}
else {
dir=${d[0]};
} fi;
cd ${dir} &&
make clean && {
make update ||
make install;
}
I'd like to replace the first part of the if/else/fi with:
if ((n > 1)); then {
select dir in ${d[@]}; do {
break;
} done;
}
else { ...
...but select breaks on the "} done;" syntax that works with, e.g.,
while sleep 5; do {
date;
} done;
until [ -f ${tmpfile} ]; do {
sleep 5;
} done;
for dir in ${d[@]}; do {
echo ${dir};
} done;
This violates the POLA, from my point of view.
Repeat-By:
d=($(ls /usr/src/pkg/*/$1));
select dir in ${d[@]}; do {
break;
} done;
- select syntax violates the POLA,
greywolf <=