Why would I not leave extglob enabled in bash?

后端 未结 2 2047
星月不相逢
星月不相逢 2020-12-07 22:09

I just found out about the bash extglob shell option here:- How can I use inverse or negative wildcards when pattern matching in a unix/linux shell?

All the answers

2条回答
  •  独厮守ぢ
    2020-12-07 22:58

    Being a Kornshell person, I have extglob on in my .bashrc by default because that's the way it is in Kornshell, and I use it a lot.

    For example:

    $ find !(target) -name "*.xml"
    

    In Kornshell, this is no problem. In BASH, I need to set extglob. I also set lithist and set -o vi. This allows me to use VI commands in using my shell history, and when I hit v, it shows my code as a bunch of lines.

    Without lithist set:

    for i in *;do;echo "I see $i";done
    

    With listhist set:

    for i in *
    do
        echo "I see $i"
    done
    

    Now, only if BASH had the print statement, I'd be all set.

提交回复
热议问题