I'm in trouble with this: what is a way to convert in pure Bourne Shell this BASH snippet?
if [[ -d "$d" ]] && [[ ! -L "$d" ]] && [[ "$OLD_PATH" =~ $d ]]; then
...omissis ...
fi
CodePudding user response:
if [ -d "$d" ]; then if [ ! -L "$d" ]; then if "$OLD_PATH" | grep -Eq "$d"; then
A variable is not something you can execute. You should print the content of the variable to grep.
if
[ -d "$d" ] &&
[ ! -L "$d" ] &&
printf "%s" "$OLD_PATH" | grep -q "$d"
then
I would consider adding -F
to grep to match it literally, or using case
- the snippet will most probably not work as intended with paths containing [
]
*
.