1
1
I have written a very simple script like this:
function apply_to_dev {
echo "Applying scripts to DEV..."
alias ISQL="isql -Uuser -Ppwd -SDEV -DDATA -I ~/bin/interfaces"
shopt -s nullglob
for f in ~/src/trunk/Database/scripts/upgrades/current/*.sh
do
echo $f
. $f
done
for f in ~/src/trunk/Database/scripts/upgrades/current/*.sql
do
echo $f
FOUT=`basename "$f"`
ISQL -i "$f" -o "$LOGDIR/$FOUT.dev.out"
done
}
apply_to_dev
When I run it I got these error messages
~/src/trunk/Database/scripts/upgrades/current/JIRA-0192.sql
~/bin/RunSQL.sh: line 48: ISQL: command not found
Why sh/bash will think ISQL is a command and not an alias. If I add 'alias' right after 'alias ISQL=...', I can see ISQL in the alias print out.
Crazy enough, the *sh files in the first for loop actually calls ISQL too. The ISQL is visible inside the *.sh files.
Is this answered by http://stackoverflow.com/questions/2197461/how-to-set-an-alias-inside-a-bash-shell-script? In particular, do you need "shopt -s expand_aliases"?
– fencepost – 2011-11-11T04:46:43.5401You do not have to use an alias for this. It is much clearer to just create a second function. – user1686 – 2011-11-11T10:22:20.360
Cannot reproduce. Please provide a minimal test case that works on any computer. – Daniel Beck – 2011-11-28T20:13:06.817