2 ms·
Tangential: I'd actually like a protocol that allows a way for external programs to ask shells to change its directory at their exit. I wonder if there are ant
by fxfan 8y ago
Tangential: I'd actually like a protocol that allows a way for external programs to ask shells to change its directory at their exit.
I wonder if there are ant security concerns to this.
- moviuro 8y agoAliases do that. I'm not sure a function or program can do that. alias mkcd='mkdir -p "$1" && cd "$1"' cd "$(something something)"
- jolmg 8y agoA function can. Coincidentally, I have a function with the same name and definition as your example. Actually, after doing a double-take on your alias, I see it can't work like you probably expect. You can't use arguments like that. It's simply substitution. If you do: mkcd someplace that'd result in: mkdir -p "$1" && cd "$1" someplace you want: mkcd() { mkdir -p "$1" && cd "$1"; } Anyway, it's subprocesses that can't control the working directory of the parent process (or other processes for that matter). A process can only control its own working directory.
- moviuro 8y agoyup, my bad! I blame that on not having a shell at work...