[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
declare -f does not output esac pattern correctly
From: |
Emanuele Torre |
Subject: |
declare -f does not output esac pattern correctly |
Date: |
Tue, 27 Feb 2024 00:50:46 +0100 |
User-agent: |
Mutt/2.2.12 (2023-09-09) |
Hello.
I have noticed that declare -f does not output valid code when a
pattern is `esac'.
To use esac as a pattern you need to use the (esac) syntax, but
declare -f does not use it, and ends up generating invalid code.
a () {
case $1 in
hi) echo hi ;;
(esac) echo esac ;;
*) echo something ;;
esac
}
$ declare -f a
a ()
{
case $1 in
hi)
echo hi
;;
esac)
echo esac
;;
*)
echo somethig
;;
esac
}
$ declare -f a | bash
bash: line 7: syntax error near unexpected token `)'
bash: line 7: ` esac)'
o/
emanuele6
- declare -f does not output esac pattern correctly,
Emanuele Torre <=