help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-bash] Why `echo !(*.l).c` behaves different depending on the conte


From: Peng Yu
Subject: [Help-bash] Why `echo !(*.l).c` behaves different depending on the context?
Date: Fri, 8 Feb 2019 22:03:34 -0600

Hi,

See below. `echo !(*.l).c` sometimes is OK but sometimes it is an
error. Is it a correct behavior?

$ ls main.c main.l.c
main.c  main.l.c
$ cat main.sh
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:

if [[ xx ]]; then
    shopt -s nullglob
    shopt -s extglob
    echo !(*.l).c
fi
$ ./main.sh
./main.sh: line 7: syntax error near unexpected token `('
./main.sh: line 7: `    echo !(*.l).c'
$ cat main.sh
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:

#if [[ xx ]]; then
    shopt -s nullglob
    shopt -s extglob
    echo !(*.l).c
#fi
$ ./main.sh
main.c

-- 
Regards,
Peng



reply via email to

[Prev in Thread] Current Thread [Next in Thread]