So I am messing around customizing my bashrc and I created a function that will move the apt proxy file depending on what parameter I pass.
It checks for two conditions either home or work (user provided) and moves the file according to where the file is currently located and what parameter it is given.
Function:
function aptproxy()
{
echo $1
if [ "$1" == 'work' -a -f /etc/apt/apt.conf.d/80proxy ]; then
echo 'You are at work'
elif [ $1 == 'work' -a !-f /etc/apt/apt.conf.d/80proxy ]; then
echo 'You are set to home, switching to work'
mv "/etc/apt/conf.d_tmp/80proxy" "/etc/apt/apt.conf.d/80proxy"
elif [ $1 == 'home' -a -f /etc/apt/apt.conf.d/80proxy ]; then
echo "You are setup for work, moving proxy"
mv "/etc/apt/apt.conf.d/80proxy" "/etc/apt/conf.d_tmp/80proxy"
elif [ $1 == 'home' a- !-f /etc/apt/apt.conf.d/80proxy ]; then
echo "You are already configured for home"
fi
}
output when calling it with one of the parameters (home or work) with set -xv
root@xubuntu:/home/user# aptproxy work
aptproxy work
+ aptproxy work
+ echo work
work
+ '[' work == work -a -f /etc/apt/apt.conf.d/80proxy ']'
+ '[' work == work -a '!-f' /etc/apt/apt.conf.d/80proxy ']'
bash: [: too many arguments
+ '[' work == home -a -f /etc/apt/apt.conf.d/80proxy ']'
+ '[' work == home -a '!-f' /etc/apt/apt.conf.d/80proxy ']'
bash: [: too many arguments
From this it looks like it is the mv commands causing the issue. I have tried them with the directories in quotes and without quotes and it yields the same results. From everything I've been reading that too many arguments error usually means a string variable is being split up into multiple pieces but with that output I don't see that happening?
Any help would be appreciated.
TIA