我只是注意到,在我的一台机器上(运行 Debian Sid),每当我输入ls
任何带空格的文件名时,它周围都有单引号。
我立即检查了我的别名,却发现它们完好无损。
wyatt@debian630:~/testdir$ ls
'test 1.txt' test1.txt
wyatt@debian630:~/testdir$ alias
alias ls='ls --color=auto'
alias wget='wget --content-disposition'
wyatt@debian630:~/testdir$
Run Code Online (Sandbox Code Playgroud)
另一个测试,文件名中包含单引号(也回答了 jimmij 的请求):
wyatt@debian630:~/testdir$ ls
'test 1.txt' test1.txt 'thishasasinglequotehere'\''.txt'
wyatt@debian630:~/testdir$ touch "'test 1.txt'"
wyatt@debian630:~/testdir$ ls
''\''test 1.txt'\''' test1.txt
'test 1.txt' 'thishasasinglequotehere'\''.txt'
Run Code Online (Sandbox Code Playgroud)
使用新的 coreutils-8.26 输出进行更新(诚然,这不那么令人困惑,但默认情况下仍然令人恼火)。感谢 Pádraig Brady 提供此打印输出:
$ ls
"'test 1.txt'" test1.txt
'test 1.txt' "thishasasinglequotehere'.txt"
$ ls -N
'test 1.txt' test1.txt
test 1.txt thishasasinglequotehere'.txt
Run Code Online (Sandbox Code Playgroud)
为什么会这样?我如何正确停止它?
需要明确的是,我自己将 ls 设置为自动彩色输出。它从来没有在事物周围加上引号。
我正在运行bash
,coreutils 8.25。
有什么方法可以在不重新编译的情况下解决这个问题?
编辑:出现 coreutils 开发人员选择)打破惯例并将其设为全局默认值。 …