On Sat, 15 Apr 2023 Max Nikulin wrote:
> On 15/04/2023 12:02,
to...@tuxteam.de wrote:
>> On Fri, Apr 14, 2023 at 11:02:03PM -0400, Greg Wooledge wrote:
>>> On Sat, Apr 15, 2023 at 09:44:03AM +0700, Max Nikulin wrote:
>>>> As to [^c] vs. [!c], unfortunately the latter can not be always used as
>>>> portable variant. It is treated as history expansion in the case of
>>>> interactive bash session.
>>>
>>> Ugh. That abomination. I've had history expansion disabled for *years*.
>>
>> You have to escape it with a backslash. Quoting with single quotes also
>> helps, although I don't know whether that is portable itself.
>
> The problem is to prevent history expansion while keeping pattern matching
> (glob) active.
>
> du -ks -- .[!.]* | sort -n | tail
Are there versions of bash that exhibit history expansion in the
example above?
davidson@parsnip:0 ~$ bash --version # In case it matters
GNU bash, version 5.1.4(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <
http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
davidson@parsnip:0 ~$ echo $- $SHELLOPTS # History expansion enabled, interactive
himBHs braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor
davidson@parsnip:0 ~$ . .bash_functions/apt-description # Populate history
davidson@parsnip:0 ~$ whee!. # Demonstrate history expansion
whee. .bash_functions/apt-description
bash: whee.: command not found
davidson@parsnip:127 ~$ du -ks -- .[!.]* | sort -n | tail # No problem!
472 .
keymap.new
816 .dvdcss
1544 .config
1884 .bash_history.d
3340 .xsession-errors
19008 .lynx
66012 .mozilla
260528 .local
348360 .cache
980500 .cabal
davidson@parsnip:0 ~$
--
Hackers are free people. They are like artists. If they are in a good
mood, they get up in the morning and begin painting their pictures.
-- Vladimir Putin