I am making a few custom commands to use on my debian server and I am putting them in the /usr/bin folder.
One custom command I wish to make involves getting the directory from where I call the script, NOT the directory in which the script resides.
Nearly all of the questions I find on here involve getting the working directory using
a=$PWD
or
a=$(pwd)
This only returns the directory in which the script resides.
Edit: I am aware of
$OLDPWD
The above will only work some of the time.
Is it possible to do what I want?
Current form of my script:
#!/bin/bash
if [ -z "$1" ]
then
a=$(pwd)
echo "Unlocking current directory."
sudo chmod 777 -R $a
else
echo "Unlocking directory at \"$1\""
sudo chmod 777 -R $1
fi