On 15/04/2023 12:02, tomas@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
Yes, somewhat annoying, unless one's making use of it.
From search engine results my impression is that there enough users of history expansion in bash and zsh. Certainly they would be angry due to a breaking changes if history expansion were disabled by default. That is why, when recommending [!c] instead of [^c], it is necessary to say "besides interactive shells such as bash and zsh". It should not be assumed that everybody has history expansion disabled.