I'm trying to write a shell script that will start Xilinx programs for me, but I am having a problem with the source command. Here is my script called xilinx
:
#!/usr/bin/env bash
cd /home/sclukey/Xilinx
source /opt/Xilinx/14.6/ISE_DS/settings32.sh
$@
If I just call xilinx
the script returns
. /opt/Xilinx/14.6/ISE_DS/common/.settings32.sh /opt/Xilinx/14.6/ISE_DS/common
. /opt/Xilinx/14.6/ISE_DS/EDK/.settings32.sh /opt/Xilinx/14.6/ISE_DS/EDK
. /opt/Xilinx/14.6/ISE_DS/PlanAhead/.settings32.sh /opt/Xilinx/14.6/ISE_DS/PlanAhead
. /opt/Xilinx/14.6/ISE_DS/ISE/.settings32.sh /opt/Xilinx/14.6/ISE_DS/ISE
but if I run xilinx ise
then the output of the source
command is missing and it just returns
/usr/local/bin/xilinx: line 4: ise: command not found
I believe this is because the source command is not running when the script is called with arguments. Why is this and how can I fix it?
Thanks
EDIT: I've discovered it is because the settings32.sh
file uses the $1
argument, and when the xilinx
script is called with arguments, those arguments also get passed to the source
command which breaks the settings32.sh
script. So how can I stop the arguments from getting passed to the source
command?
With your script, you are automating the following commands, if xilinx ise
is typed in from the command line:
$ cd /home/sclukey/Xilinx
$ source /opt/Xilinx/14.6/ISE_DS/settings32.sh
$ ise
The response from the script indicates that there's no ise
program in the path. I would check to see where ise
is, and if settings32.sh
sets up a path for it.
It seems like /opt/Xilinx/14.6/ISE_DS/settings32.sh
or one of the scripts it source
's responds to command-line argument and swallows them. Try saving them before sourcing, then wiping them:
#!/usr/bin/env bash
args=$@
shift
cd /home/sclukey/Xilinx
source /opt/Xilinx/14.6/ISE_DS/settings32.sh
$args
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.