Linux command line for you and me
lym.readthedocs.io
lym.readthedocs.io
$ cat /usr/bin/cd
#!/bin/sh
# $FreeBSD: src/usr.bin/alias/generic.sh,v 1.2 2005/10/24 22:32:19 cperciva
Exp $
# This file is in the public domain.
builtin `echo ${0##*/} | tr \[:upper:] \[:lower:]` ${1+"$@"}
Although it didn't behave as expected when invoked ...(And yes, I'm the cperciva in that version tag.)
Makes my day that you could discover this post - Thanks so much for chiming in !
A lot of commands are also built-in for convenience but don't strictly need to be.
https://unix.stackexchange.com/questions/50058/what-is-the-p...
Yes, it's idiotic.
I don't understand what you meant is idiotic though
By idiotic I think it's a mistake to blur the line between shell builtins and external commands.
Theoretically you could also have a cd that would IPC the shell to change the pwd but I guess you could also say that is overengineering.
cd -
This takes you to the last directory you were in (not the same as cd .. which takes you one level up) $ pwd
/foo
$ pushd /bar && pwd
/bar
$ pushd /quux && pwd
/quux
$ popd && pwd
/bar
$ popd && pwd
/foo
So it's basically a stack.Never seen {push,pop}d in a shell script.
As an interactive feature, I use the "autopushd" option in zsh, which make all "cd" behave like pushd, and you can also use "cd -n" where "n" is the number of levels you want to go up the stack (so "cd -" is equivalent to "cd -1")