r/linux_programming • u/reflect_elegant • Oct 22 '20
Converting script to Posix compliant
Is there a way to make this section of a larger script Posix compliant?
options=$(lsblk | awk '/disk/ { print $1 }')
select opt in $options; do
if [ -n "$opt" ]; then
DEV_DISK_NAME="/dev/${opt}"
DEV_PART_NAME="/dev/${opt}"
break
else
printf 'This option is invalid.\n\n'
fi
done
4
Upvotes
View all comments
1
u/balsoft Oct 22 '20
First iteration would be
shellcheck -s shSo, replace that
selectloop somehow.Also, AFAIR
lsblkis not POSIX, so you probably need to replace it with something POSIX.