Problem with ebook scripts
rrthomas opened this issue · 4 comments
rrthomas commented
The ebook scripts contain the idiom:
script_dir=$(cd $(dirname $0) && pwd)
cd $script_dir/../..
There are two problems here:
- It's not great for scripts to change directory like this. I would be happier to see
script_dir
used as a prefix to paths where needed. cd
outputs text to stdout when it matches an entry inCDPATH
. I have.
in myCDPATH
, so most times I usecd
, there is output. This breaks the script. It would of course be possible just to unsetCDPATH
, but is there some reason why the line above can't be replaced with just:
script_dir=$(dirname $0)
? (WFM!)
entorb commented
I used this to to ensure that the current working dir is the hpmor base.
If there is a more elegant way to do it, I am happy to change it.
Alternatively, instead of cd to that dir, I could perform a check for the presence of "chapters/" dir in current dir and exit if not found.
rrthomas commented
I think the simplest change here is the "more elegant way" I suggest in number 2 above; does that work for you? It should be correct, but I wonder why a more complicated command was used before…
rrthomas commented
Thanks, this fixes things for me, closing.