Firstly come background I am trying to write an executable shell script I can easily map as the default for .tgz files to auto-extract.
so far so simple
tar -xzvf $1
which works to drag/drop but not if I double click. Since I can use it if files are in the same location I assume it is because of the current working directory of the script.
However equally shouldn't $1 pass the full file path to the tar command so it doesn't matter?
Anyway I then thought the answer would be the pwd command then the dirname command i.e.
cd 'dirname $1'
but that didn't work A google around suggested
cd -P -- "$(dirname -- "$1")" && pwd -P
But I still can't get this script to work. It may not be the right error.