In thread Date Format Problem , Aia and I were discussing the usefulness of using #!/usr/bin/env bash (or ksh, or perl, or ...) as the shebang line. The exchange was good, but it was getting beyond the scope or the thread, so I decided to continue it here.
My preference is in favor of using it, while Aia wrote:
Quote:
Originally Posted by Aia
Nothing bits knowing the targets you are coding for. env can have the same problem that you are trying to solve, the binary could be in different location in different OSes. Also, it increases the risk of selecting the wrong interpreter, since it looks in each directory in the path, choosing the first one that it finds.
and
Quote:
Originally Posted by Aia
A casual perusing of the wikipidia entry for Shebang (Unix) shows a couple examples of systems that do not have an /usr/bin/env , under the portability subtitle.
My reply to this is that in that same Wikipedia link, we see:
Quote:
Often, the program /usr/bin/env can be used to circumvent this limitation [that is: Even when systems have fairly standard paths, it is quite possible for variants of the same operating system to have different locations for the desired interpreter] by introducing a level of indirection. #! is followed by /usr/bin/env, followed by the desired command without full path ... https://en.wikipedia.org/wiki/Sheban...29#Portability
The exceptions noted in that Wikipedia article are:
To which I say, if someone is porting to such earlier SCO or Cray OSs (or even to current implementations), they probably will have many more troubles than just the shebang line. Researchers don't usually run just shell scripts on Cray, etc. machines, they run very large, complex codes. The number of people using such machines are far in the minority compared to the other systems I mentioned in an earlier post.
(If it has been noted that I am from Minnesota, one might speculate that I have some connection with Unicos on Cray computers. Indeed I worked at the University of Minnesota and the associated Minnesota Supercomputer Center for about 25 years. We handled really big iron. If memory serves, when I left MSC, we had 3 Crays, an ETA-10, a Thinking Machines CM-2 (32K single-bit processors, ganged together to 1000 processors, SIMD), a TMC CM-5 (MIMD), a pair of 6-CPU IBM 3090s t(ied together through some very large memory accessory), and probably some other gear I have forgotten.
I live now in the suburbs, but even so, I live within walking distance to at least 5 colleagues who worked at Cray or MSC or both, including one who is a co-author of O'Reilly's bash Cookbook, from where I got the env shebang idea. It is worth noting that in that book one can find:
Quote:
If your system does not have env in /usr/bin, ask your system administrator to install it, move it, or create a symbolic link because that is the required location. https://books.google.com/books?id=06...in/env&f=false
)
In summary, my conclusion is that #!/usr/bin/env is a very good solution to the problem of portability among the many environments that I often encounter, but to each their own.
Hi,
Please clarify what is the difference between "env" and "set" command.
I guess set will display the system variables and user defined variables.
Thanks
Sweta (1 Reply)
Hi Friends,
Can any of you explain me about the below line of code?
mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`
Im not able to understand, what exactly it is doing :confused:
Any help would be useful for me.
Lokesha (4 Replies)
I need to take a string (stringA) check it for spaces and replace any spaces found with an equal (=) sign.
This is not working. There are spaces between each component:
$StringA | tr "" ""
The error returned is:
test: Specify a parameter with this command
Can you help? (3 Replies)
I am using ksh.. Whenever we write a shell script the first statement would be #! /bin/ksh. But instead of that I came to find "#@$-q large" in the first line and"#@$-s /usr/bin/ksh -x " in the second line. what does it mean?
Give your comments.....
Thanks
sabeer (4 Replies)
Hi,
could someone pls enlighten me on the difference between the "root" package and "usr" package?
Like in this example:
pkginfo -l SUNWGtku | grep -i desc
DESC: GTK - The GIMP Toolkit (Usr)
and
pkginfo -l SUNWGtkr | grep -i desc
DESC: GTK - The GIMP Toolkit (Root)... (6 Replies)
On a SunOS Solaris 5.5.1 workstation, the /usr/dt/bin/sdtdbcache –init command lasts more than 20 minutes. This command is executed by the /usr/dt/bin/Xsession script during an user connection.
Please refrain from using subjects like "HELP ME!..." to get more/faster attention and also please do... (1 Reply)
what if the difference between
#!/bin/sh
and
#!/bin/bash
I wrote a script with the second heading now when i change my heading to the first one ...the script is not executing well....im not getting the required output....any solution to this problem...or do i have to start the... (3 Replies)
The system don't boot.
on the screen appears following:
press enter to maintenance (or type CTRL-D to continue)...I checked with format command.
... the slices "0-root","1-swap","2-backup" exist.
...the slises "3-var","6-usr" -unassigned. :( (16 Replies)
I'm on Ubuntu 14.04 and I manually updated my coreutils so that "tee" is now on version 8.27
I was running a script using bash where there is some write to pipe error at some point causing the tee command to exit abruptly while the script continues to run. The newer version of tee seems to prevent... (2 Replies)