I have this:
function abash {
if [[ -v $1 ]]
then
atom ~/Shell/$1.sh
else
atom ~/.bashrc
fi
}
in my ~/.bashrc file, so as to make it easier to use Atom to edit my bash scripts, now the problem is that [[ -v $1 ]] is meant to be checking whether the input $1 exists but it does not appear to be, as even when I provide a valid input (e.g., running abash cd where ~/Shell/cd.sh is a file I want to edit) abash opens up ~/.bashrc. How do I fix this problem? Where did I get the idea for the [[ -v $1]] test? This answer.
#here as command start. – Mingye Wang Oct 28 '15 at 05:15[ $# > 0 ]just as well and have it portable? – Wildcard Oct 28 '15 at 06:53[; you'd have to use[ $# -gt 0 ]instead. – Sparhawk Oct 28 '15 at 09:07