doinst.sh syntax (help please)
I'm currently adding packages to my slackware install cd's and I've finally come to a point where I do need to write a doinst.sh script to sort a few things out after the installation..
I need the packages to install and word inside the slackware installer.. so I suppose they should be ash-compatible. I've seen a few scripts inside packages such as: ( cd /path/to/program; ln -s link sourcefile ) ( cd /path/to/program; ln -s link2 sourcefile2 ) Now.. that hardly look like my average bash script.. Is it not possible for me to just omit parenthesises and handle the same action like so: cd /path/to/program ln -s link sourcefile ln -s link2 sourcefile2 And can't I just use if-blocks, for-loops and so on like I usually do with bash scripts ? The reason I ask is because the tutorial on linuxpackages.net show regular sh syntax but the scripts I've seen in doinst.sh files so far show the other syntax... Please help :) |
The effect of the parentheses is to fire off a subshell to do the work within those parentheses, and then come back to your original shell.
In the example you cite, this aspect is important. When you come back to the main shell, your current directory is as it was before you did the work. Try this at your shell prompt: pwd (cd /; pwd) pwd cd ;/ pwd pwd .. and you'll see what the parentheses buy for you. |
The doinst.sh is just a shell script. You have to take into account though that when you have a package on the install CD, the shell it runs in is not bash but the less powerful "ash" (which does not have all of the functionality of the bigger bash). So you should check your script against the ash manual perhaps.
Most standard shell scripting commands will be handled properly by ash, so I expect no real problems here. An important thing to know is that you should not use absolute paths in the doinst.sh script. That is why you'll see lines like Code:
config etc/rc.d/rc.httpd.new Code:
config /etc/rc.d/rc.httpd.new Eric |
Thanks a lot to both of you :)
I'll keep both things in mind and hopefully my packages won't blow up during installation or anything :rolleyes: |
All times are GMT -5. The time now is 05:10 AM. |