2025年2月20日(木) 20:51 Timotei Campian <timoteicamp...@gmail.com>:
> echo !(file.f*)
>
>  *bash --pretty-print test.sh*

If this script file "test.sh" will be used as an independent
executable file, to make it work, you need to put "shopt -s extglob"
at the beginning of the file as Greg explained in the other reply. If
the script file is supposed to be sourced by another file where
"extglob" is enabled, you don't have to set "shopt -s extglob" again
at the beginning of the file.

However, even if you make sure that "extglob" is enabled when the
script file is parsed in real situations as described above,
"--pretty-print" still doesn't work because it doesn't execute the
file at all. To parse and print a file with the actual set of shell
options that the file is supposed to be parsed, you need to set them
in the command-line options of Bash. In the present case, you can run
it in the following way:

$ bash --pretty-print -O extglob test.sh

--
Koichi

Reply via email to