Sponsored Content
Top Forums Shell Programming and Scripting How to trap set -o nounset in bash Post 302534703 by DGPickett on Tuesday 28th of June 2011 02:01:50 PM
Old 06-28-2011
It is just a bit in VM, where is the signal?

Why not avoid touching unset variables in the trap or whatever ?

Code:
$ truss bash -c 'set -u ; echo mark ; echo $haha'
execve("/ndmtest/clmstux/nbkodln/myroot/usr/local/bin/bash", 0x7b0f54b8, 0x7b0f54c8) = 0 [32-bit]
 .
 .
 .
sigsetstatemask(0x17, NULL, 1073851480)                    = 0
getpeername(0, 0x7b0f59a0, 0x7b0f599c)                     ERR#216 ENOTSOCK
sigsetstatemask(0x17, NULL, 1073851480)                    = 0
sigsetstatemask(0x17, NULL, 1073851480)                    = 0
mark
write(1, "m a r k \n", 5)                                  = 5
bash: haha: unbound variable
write(2, "b a s h :   h a h a :   u n b o ".., 29)         = 29
sigsetstatemask(0x17, 0x4001ac58, 0)                       = 0
sigsetstatemask(0x17, 0x4001ac58, 0)                       = 0
exit(127)


Last edited by DGPickett; 06-28-2011 at 03:07 PM..
 

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
LIBBASH(7)							  libbash Manual							LIBBASH(7)

NAME
libbash -- A bash shared libraries package. DESCRIPTION
libbash is a package that enables bash dynamic-like shared libraries. Actually its a tool for managing bash scripts whose functions you may want to load and use in scripts of your own. It contains a 'dynamic loader' for the shared libraries ( ldbash(1)), a configuration tool (ldbashconfig(8)), and some libraries. Using ldbash(1) you are able to load loadable bash libraries, such as getopts(1) and hashstash(1). A bash shared library that can be loaded using ldbash(1) must answer 4 requirments: 1. It must be installed in $LIBBASH_PREFIX/lib/bash (default is /usr/lib/bash). 2. It must contain a line that begins with '#EXPORT='. That line will contain (after the '=') a list of functions that the library exports. I.e. all the function that will be usable after loading that library will be listed in that line. 3. It must contain a line that begins with '#REQUIRE='. That line will contain (after the '=') a list of bash libraries that are required for our library. I.e. every bash library that is in use in our bash library must be listed there. 4. The library must be listed (For more information, see ldbashconfig(8)). Basic guidelines for writing library of your own: 1. Be aware, that your library will be actually sourced. So, basically, it should contain (i.e define) only functions. 2. Try to declare all variables intended for internal use as local. 3. Global variables and functions that are intended for internal use (i.e are not defined in '#EXPORT=') should begin with: __<library_name>_ For example, internal function myfoosort of hashstash library should be named as __hashstash_myfoosort This helps to avoid conflicts in global name space when using libraries that come from different vendors. 4. See html manual for full version of this guide. AUTHORS
Hai Zaar <haizaar@haizaar.com> Gil Ran <ril@ran4.net> SEE ALSO
ldbash(1), ldbashconfig(8), getopts(1), hashstash(1) colors(1) messages(1) urlcoding(1) locks(1) Linux Epoch Linux
All times are GMT -4. The time now is 07:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy