From 2847b020b405b3fce7c7b58f55d9f482d1a18924 Mon Sep 17 00:00:00 2001 From: Michael Klement Date: Wed, 3 Dec 2014 09:48:49 -0500 Subject: [PATCH] Make sure that CDPATH isn't set, as it causes `cd` to behave unpredictably - notably, it can produce output, which breaks fullpath(). Also: Improved CLI help, updated URLs in read-me, cleaned up package.json: I've tried to clarify the intent of `-x` in the CLI help, but I haven't touched the read-me in that respect. I don't see any benefit to `-x`: * Just using `#/bin/sh` as the shebang line in combination with `-s ` gives you the same functionality, * When it comes to invoking scripts from _within_ test scripts, nothing can do the work for you: you consciously have to mark the invocation with _something_ to indicate that it should be controlled from the outside; it won't get any easier than `$TEST_SHELL ...` * Finally, using a shebang line such as `#!/usr/bin/env urchin -x` is problematic for two reasons: * Some platforms can handle only *1* argument in a shebang line. * In a _package-local_ installation, `#!/usr/bin/env` may not find the Urchin executable. I'm also not sure how the following (from `readme.md`) fits in the picture: > It might make sense if you do this. export TEST_SHELL=zsh && urchin -x export TEST_SHELL=bash && urchin -x (As an aside: To achieve the same thing, you don't need `export`; `TEST_SHELL=zsh urchin -x` and `TEST_SHELL=bash urchin -x` is the better choice.) How does this relate to use in a _shebang line_? `urchin_help()` now uses a here-doc: easier to maintain, and should work in all Bourne-like shells. `readmeFilename` removed from `package.json`: > "The readmeFilename does not need to ever be in your actual package.json file" - npm/npm#3573 --- tests/A nonempty CDPATH should not break urchin. | 6 ++++++ urchin | 4 ++++ 2 files changed, 10 insertions(+) create mode 100755 tests/A nonempty CDPATH should not break urchin. diff --git a/tests/A nonempty CDPATH should not break urchin. b/tests/A nonempty CDPATH should not break urchin. new file mode 100755 index 0000000..cd585ec --- /dev/null +++ b/tests/A nonempty CDPATH should not break urchin. @@ -0,0 +1,6 @@ +#!/bin/sh + +cd .. +export CDPATH=$PWD +./urchin -f 'tests/urchin exit code' >/dev/null + diff --git a/urchin b/urchin index 3443ea5..b243290 100755 --- a/urchin +++ b/urchin @@ -1,5 +1,9 @@ #!/bin/sh +# Make sure that CDPATH isn't set, as it causes `cd` to behave unpredictably - notably, it can produce output, +# which breaks fullpath(). +unset CDPATH + fullpath() { ( cd -- "$1"