1

在我的用例中,我想生成一个将当前目录设置为特定目录的 shell,供用户执行一些操作,问题是用户经常PS1设置打印当前工作目录,我不想要一个很长的荒谬路径如果他们指定的目录是软链接的目录(到同一个目录但路径名称更短,请参见下面的示例),则显示出来。

然而,这种行为似乎无处不在,我不知道是否有办法:

$ cd /tmp
$ mkdir -p some/ridiculously/long/path/name/that/no/one/wants/to/see
$ ln -s /tmp/some/ridiculously/long/path/name/that/no/one/wants/to/see s
$ ghci
GHCi, version 8.8.3: https://www.haskell.org/ghc/  :? for help
Prelude> import System.Directory
Prelude System.Directory> setCurrentDirectory "/tmp/s"
Prelude System.Directory> getCurrentDirectory 
"/tmp/some/ridiculously/long/path/name/that/no/one/wants/to/see"

turtle's cd/也是如此pushd,它似乎使用system-fileio而不是directory,但相同的行为仍然存在。我知道CreateProcessprocess一个cwd记录字段可以在我即将生成 shell 时设置,但这似乎也是如此。所以我已经没有什么可以尝试的想法了。

4

0 回答 0