How to switch current working directory while not resolving realpath in Haskell?

143 Views Asked by At

In my use case, I want to spawn a shell with current directory set to a specific one for users to perform some operations, the problem is user often have their PS1 set to print current working directory and I don't want a long ridiculous path to show up if the directory they've specified is a soft linked one (to that same directory but with a way shorter path name, see my example below).

However this behavior seems to be everywhere and I don't know if there is a way around:

$ 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"

Same goes for turtle's cd / pushd, which seems to use system-fileio instead of directory, but the same behavior remains. I know CreateProcess of process has a cwd record field I can set when I'm about to spawn the shell but that seems to do the same. So I've run out of ideas on what else to try.

0

There are 0 best solutions below