Sponsored Content
Top Forums Shell Programming and Scripting How to trap set -o nounset in bash Post 302535024 by DGPickett on Wednesday 29th of June 2011 11:40:20 AM
Old 06-29-2011
It is possible to test before you touch. Personally, I turn it off and write scripts where unset and "" are equivalent. It makes for more code and more ways to fail, more costly than can be offset by any speed it adds to debugging!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to trap unix signal if the process killed/interupt occured in bash...

hey champs, I have a process running.......i have to catch/trap the signal when the process is being interupted/killed (kill -9 pid) option...... how can i achieve the same thru my process........ let my process is a.sh and it supposed to take 13 mins to complete, but due to some problem ,... (15 Replies)
Discussion started by: manas_ranjan
15 Replies

2. Shell Programming and Scripting

test-and-set in bash

I'm not talking about the assembly instruction TAS, a better name could be check-and-set :) Anyway, is there a way to simplify the following if ; then VAR="something"; fi I have ~20 variables that should be test-and-set like this, and it really looks lame. (2 Replies)
Discussion started by: rayne
2 Replies

3. Shell Programming and Scripting

Cntl+z Trap is not detecting ??? Help required to add a trap detection ???

Hi folks, I have tried to add some trap detection in the below script....this script is used to monitor database activities...in a rather awkward way :rolleyes:.... The idea behind adding trap is that....this script creates lots of temporary files in the running folder to store the count... (1 Reply)
Discussion started by: frozensmilz
1 Replies

4. Shell Programming and Scripting

Bash Trap Problem?

Hey all, I'm a fairly new shell scripter (been writing some very basic stuff for a couple of years once in a blue moon). I have the need to start 2 or 3 processes from within a bash script when it's run then have the script kind of hang out and wait for the user to ctrl+c and when that happens... (3 Replies)
Discussion started by: jsabino
3 Replies

5. Shell Programming and Scripting

Record the Signal Type or Number in Bash Trap function

In my Bash script I have an exit/cleanup function in a trap statement like: trap exitCleanup 1 2 3 6 15 25 Is there anyway to capture which signal # has occurred to record in a log file. Please note I am trying to avoid something like: trap 'mySignal=1; exitCleanup' 1 trap... (1 Reply)
Discussion started by: ckmehta
1 Replies

6. Homework & Coursework Questions

VM trap may work differently than a pure install trap.

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: That is the last reply I received from my instructor, and I'm looking for some alternatives. When using... (2 Replies)
Discussion started by: newuser45
2 Replies

7. Shell Programming and Scripting

Shell script to set trap for finding cron job failures

Unix box: solaris 5.8 Server: IP Need to to set trap for cron job failures by writing a shell script (5 Replies)
Discussion started by: ChandruBala73
5 Replies

8. Shell Programming and Scripting

Bash - trap error file not found

Hello. In bash, is there a way to trap error "file not found" when a script call another script which is not found; then abort. Example ( part of script running with -x option set) : + return 0 + RETURN_CODE=0 + ] + /root/bin/200_yast_install/00_reset_yast_install bash:... (5 Replies)
Discussion started by: jcdole
5 Replies

9. Shell Programming and Scripting

How do i check if all parameters are set in bash?

Hi, I have 4 parameters passed to my shell and i validate if all four are entered using the following snippet: if then echo "Not entered" else echo "entered" fi I get the following output as 'Not entered even when i enter the values for all prompts. Please advise. Thanks. (5 Replies)
Discussion started by: Jesshelle David
5 Replies

10. Shell Programming and Scripting

Bash set dummy ?

Could somebody please provide me with verbatim description / purpose of the following ? set dummy $ac_prog; ac_word=$2 set dummy $ac_tool_prefix; ac_word=$2 could it be written set dummy $ac_prog; ac_word=$2 set dummy $ac_tool_prefix; ac_word=$2 (9 Replies)
Discussion started by: anne
9 Replies
getpflags(2)															      getpflags(2)

NAME
getpflags, setpflags - get or set process flags SYNOPSIS
#include <sys/types.h> #include <priv.h> uint_t getpflags(uint_t flag); int setpflags(uint_t flag, uint_t value); The getpflags() and setpflags() functions obtain and modify the current per-process flags. The following values for flag are supported: PRIV_AWARE This one bit flag takes the value of 0 (unset) or 1 (set). Only if this flag is set is the current process privilege- aware. A process can attempt to unset this flag but might fail silently if the observed set invariance condition cannot be met. Setting this flag is always successful. See privileges(5) for a discussion of this flag. PRIV_DEBUG This one bit flag takes the value of 0 (unset) or 1 (set). Only if this flag is set does the current process have privi- lege debugging enabled. Processes can set and unset this flag at will. The getpflags() returns the value associated with a given per-process flag. If the flag argument is invalid, (uint_t)-1 is returned and errno is set to indicate the error. Upon successful completion, setpflags() returns 0. Otherwise, -1 is returned and errno is set to indicate the error. The getpflags() and setpflags() functions will fail if: EINVAL The value of flag or the value to which the flag is set is out of range. The setpflags() function will fail if: EPERM An attempt was made to unset PRIV_AWARE but the observed set invariance condition was not met. See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ |MT-Level |Async-Signal-Safe | +-----------------------------+-----------------------------+ ppriv(1), attributes(5), privileges(5) 7 Mar 2005 getpflags(2)
All times are GMT -4. The time now is 05:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy