我观察到 Bash 中有一个行为只发生在我的主文件夹中。我无法在其他任何机器或其他文件夹中重现该行为。
$ echo --one [--two] --three
--one f --three
$ # Huh?
$ echo [--two] # Why is echo changing my string?
f
$ echo --two # Does it happen without the brackets?
--two
$ echo [--x] --x # Does it happen with a different string?
f --x
$ echo [--arg] --arg # So anything within [-- ... ] changes to f?
[--arg] --arg
$ # WHAT?
$ echo [-x] [--x] [---x] # Does the number of hyphens matter?
[-x] f [---x]
$ cd ./folder; echo [--x]
[--x]
$ # ?????
所以这只发生在我的主文件夹中。为什么?
f
我在 Bash 手册中找不到任何关于将字符串扩展为的内容。为什么有些字符串可以扩展为f
,而有些却不行?可能是我的 IFS 的问题吗?我尝试完全清空我的~/.bashrc
,但问题仍然存在。然而,当我在alpine
Docker 容器中尝试这样做时,却无法进行f
扩展。这是怎么回事?
(发布此帖子是因为我找到了解决方案,这相当令人尴尬。)