Sponsored Content
Top Forums Shell Programming and Scripting Discussion: use "/usr/bin/env" or not Post 302973161 by Aia on Sunday 15th of May 2016 01:18:43 PM
Old 05-15-2016
Hi drl,

The topic of using env as a _silver bullet_ for portability in the Unices world has been discussed extensively on many forums and a quick search on the Net will produce many of those conversations.

Your experience, certainly, will contribute to how strongly you feel about a particular topic. However, portability is an elusive concept, as much as we would like to believe not so. The classic _it has worked for me for so many years_ or _I have never had a problem with it_ does not produce an assurance of portability, neither. And since this could be a call to _holy war_ for many, I would like to leave it there, on my part.

My original objective was to bring awareness that by using env you might be trading a _minor_ inconvenience (merely the need to know what systems you are coding for) for a whole new set of issues.

Thank you for including my post.
 

10 More Discussions You Might Find Interesting

1. Programming

Differece between "env" and "set" command

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)
Discussion started by: sweta
1 Replies

2. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

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)
Discussion started by: Lokesha
4 Replies

3. UNIX for Dummies Questions & Answers

#!/bin/sh script fails at StringA | tr "[x]" "[y]"

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)
Discussion started by: by_tg
3 Replies

4. Shell Programming and Scripting

What does "#@$-s /usr/bin/ksh -x " mean?

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)
Discussion started by: sabeeralict
4 Replies

5. Solaris

difference between "root" and "usr" packages

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)
Discussion started by: masloff
6 Replies

6. Solaris

Execution problem with "/usr/dt/bin/sdtdbcache

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)
Discussion started by: ricadom
1 Replies

7. UNIX for Dummies Questions & Answers

Difference between "/bin/bash" & "/bin/sh"

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)
Discussion started by: xerox
3 Replies

8. Solaris

The slices "usr", "opt", "tmp" disappeared!!! Help please.

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)
Discussion started by: wolfgang
16 Replies

9. Shell Programming and Scripting

If cmd in in "A/user/bin A/bin A/user/sbin" but not "B/user/bin B/bin B/user/sbin" directory print t

there are two directories A and B if cmd in in "A/user/bin A/bin A/user/sbin" but not "B/user/bin B/bin B/user/sbin" directory print them (1 Reply)
Discussion started by: yanglei_fage
1 Replies

10. Shell Programming and Scripting

Mindboggling difference between using "tee" and "/usr/bin/tee" in bash

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)
Discussion started by: stompadon
2 Replies
SETJMP(3)						   BSD Library Functions Manual 						 SETJMP(3)

NAME
sigsetjmp, siglongjmp, setjmp, longjmp, _setjmp, _longjmp, longjmperror -- non-local jumps LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <setjmp.h> int sigsetjmp(sigjmp_buf env, int savemask); void siglongjmp(sigjmp_buf env, int val); int setjmp(jmp_buf env); void longjmp(jmp_buf env, int val); int _setjmp(jmp_buf env); void _longjmp(jmp_buf env, int val); void longjmperror(void); DESCRIPTION
The sigsetjmp(), setjmp(), and _setjmp() functions save their calling environment in env. Each of these functions returns 0. The corresponding longjmp() functions restore the environment saved by the most recent invocation of the respective setjmp() function. They then return so that program execution continues as if the corresponding invocation of the setjmp() call had just returned the value specified by val, instead of 0. Pairs of calls may be intermixed, i.e., both sigsetjmp() and siglongjmp() as well as setjmp() and longjmp() combinations may be used in the same program. However, individual calls may not, e.g., the env argument to setjmp() may not be passed to siglongjmp(). The longjmp() routines may not be called after the routine which called the setjmp() routines returns. All accessible objects have values as of the time longjmp() routine was called, except that the values of objects of automatic storage invo- cation duration that do not have the volatile type and have been changed between the setjmp() invocation and longjmp() call are indetermi- nate. The setjmp()/longjmp() function pairs save and restore the signal mask while _setjmp()/_longjmp() function pairs save and restore only the register set and the stack. (See sigprocmask(2).) The sigsetjmp()/siglongjmp() function pairs save and restore the signal mask if the argument savemask is non-zero. Otherwise, only the reg- ister set and the stack are saved. In other words, setjmp()/longjmp() are functionally equivalent to sigsetjmp()/siglongjmp() when sigsetjmp() is called with a non-zero savemask argument. Conversely, _setjmp()/_longjmp() are functionally equivalent to sigsetjmp()/siglongjmp() when sigsetjmp() is called with a zero-value savemask. The sigsetjmp()/siglongjmp() interfaces are preferred for maximum portability. ERRORS
If the contents of the env are corrupted or correspond to an environment that has already returned, the longjmp() routine calls the routine longjmperror(3). If longjmperror() returns, the program is aborted (see abort(3)). The default version of longjmperror() prints the message ``longjmp botch'' to standard error and returns. User programs wishing to exit more gracefully should write their own versions of longjmperror(). SEE ALSO
sigaction(2), sigaltstack(2), sigprocmask(2), pthread_sigmask(3), signal(3) STANDARDS
The setjmp() and longjmp() functions conform to ANSI X3.159-1989 (``ANSI C89''). The sigsetjmp() and siglongjmp() functions conform to ISO/IEC 9945-1:1990 (``POSIX.1''). CAVEATS
Historically, on AT&T System V UNIX, the setjmp()/longjmp() functions have been equivalent to the BSD _setjmp()/_longjmp() functions and do not restore the signal mask. Because of this discrepancy, the sigsetjmp()/siglongjmp() interfaces should be used if portability is desired. Use of longjmp() or siglongjmp() from inside a signal handler is not as easy as it might seem. Generally speaking, all possible code paths between the setjmp() and longjmp() must be signal race safe. Furthermore, the code paths must not do resource management (such as open(2) or close(2)) without blocking the signal in question, or resources might be mismanaged. Obviously this makes longjmp() much less useful than previously thought. BSD
June 1, 2008 BSD
All times are GMT -4. The time now is 09:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy