我只是注意到,在我的一台机器上(运行 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 开发人员选择)打破惯例并将其设为全局默认值。 …
当我查看一个很大的差异时git diff,它会被分页less。这是通过打开另一个窗口,从检查的数据证实ps -aux和/proc。
但是,当less被 Git 调用时,它不会将终端内容在命中后恢复到之前的状态q(差异内容保留在终端中)。但是当我这样做时
git diff commit1 commit2 --color | less -R
Run Code Online (Sandbox Code Playgroud)
并按less键退出q,内容消失,终端恢复到之前的状态。
更有趣的是,如果我做这些
export PAGER=less LESS='-R'
Run Code Online (Sandbox Code Playgroud)
和 invoke git diff(或任何其他调用寻呼机的命令)的less行为与直接从 Bash shell 调用一样。
这是描述我的问题的简短屏幕截图。在左侧窗格中,命令执行如下:
unset PAGER GIT_PAGER LESS
git diff HEAD^ HEAD
Run Code Online (Sandbox Code Playgroud)
在右侧窗格中,您会看到命令。最新的提交是 100 多行y写入文件。在两个窗格上less都使用 key 退出q。
谁能告诉我有什么不同并解释为什么?