我正在写一个bash脚本.我需要当前的工作目录始终是脚本所在的目录.
默认行为是脚本中的当前工作目录是我运行它的shell的目录,但我不想要这种行为.
bash scripting path
例:
absolute="/foo/bar" current="/foo/baz/foo" # Magic relative="../../bar"
我如何创造魔法(希望不是太复杂的代码......)?
bash shell path relative-path absolute-path
bash ×2
path ×2
absolute-path ×1
relative-path ×1
scripting ×1
shell ×1