4 ms·
I still wonder why `cd` doesn't have a form `cd dir command...`, as in `cd dir tar xf -`.
by apk17 9y ago
I still wonder why `cd` doesn't have a form `cd dir command...`, as in `cd dir tar xf -`.
- efaref 9y agoYou could quite easily write a script that does this: #!/bin/sh cd $1 shift exec "$@" It's a shame "in" is a reserved word, because that'd be a good name for it. Maybe "cde" for "cd-exec": tar c files | ssh dest cde /some/dir tar x
- apk17 9y agoMine is called cdx and includes 'env' functionality and a bit more. (https://github.com/apk/c-utils/blob/master/aenv.c https://github.com/apk/c-utils/blob/master/aenv.c)
- dasyatidprime 9y agoThe form I usually use is (cd TARGET && COMMAND), including the parentheses to make it a subshell. That seems close enough to not be worth adding features to something as simple as cd, given the basic shell philosophy of composability.