Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Problems with "exit" called from function in bourne script Post 302633629 by vacadepollo on Wednesday 2nd of May 2012 09:17:04 AM
Old 05-02-2012
Quote:
Originally Posted by neutronscott
No... Seems like behavior of break. Are you sure /sbin/sh is busybox's? Seems like an odd place. Thought Android put it in /system/xbin or something. It may have -x option to trace. if you run sh -x script you should see nothing after + exit ...
mmmm I know, but it happens.

OK, my fault, sorry, EXITING is called from other function, this is the problem.

the "for" loop call "CHECKING" and then call "EXITING" , but only break the "for" loop, and get the same behavior, show me "OK" echo.

(*this is a sample to show the concept)



test.sh
Code:
#!/sbin/sh

CHECKING()
{
	EXITING 0
}



EXITING()
{
        exit 0      
} 



for i in ls ;do
  ls *.tar* | while read i;do
      echo "Hello"
      CHECKING
  done
done

echo "OK"



sh -x test.sh
Code:
/emmc # sh -x test.sh
+ sh -x test.sh
+ read i
+ ls Backup.tar p7zip.tar.bz2
+ echo Hello
Hello
+ CHECKING
+ EXITING 0
+ exit 0
+ echo OK
OK


I use "#!/sbin/sh" because my script in some point makes a /system format and need the busybox integrated in the recovery, not the included in /system. And /sbin/sh is the standard path to launch the shell from recovery.

Last edited by vacadepollo; 05-02-2012 at 10:27 AM..
 

10 More Discussions You Might Find Interesting

1. HP-UX

ERROR: more than one instance of overloaded function "vprintf" has "C" linkage

Hi people! I've got this own library: -------------------------------------------- Personal.h -------------------------------------------- #ifdef __cplusplus extern "C" { #endif #include <stdio.h> #include <stdarg.h> #include <string.h> ... (0 Replies)
Discussion started by: donatoll
0 Replies

2. UNIX for Advanced & Expert Users

All alias in .profile lost when "script" command is called

Hi, I was trying to call "script <an ip add>" command from .profile file to log everything whenever anyone logs in to this user. I did the following at the end of .profile. 1) Extracted the IP address who logged in 2) Called script < ip add> . The problem I am facing is all, aliases etc. written... (3 Replies)
Discussion started by: amicon007
3 Replies

3. Shell Programming and Scripting

read -p "prompt text" foo say "read: bad option(s)" in Bourne-Shell

Hallo, i need a Prompting read in my script: read -p "Enter your command: " command But i always get this Error: -p: is not an identifier When I run these in c-shell i get this error /usr/bin/read: read: bad option(s) How can I use a Prompt in the read command? (9 Replies)
Discussion started by: wiseguy
9 Replies

4. Shell Programming and Scripting

Ksh script function, how to "EXIT 2" without killing the current process?

Hi, Using AIX 5.3 and Ksh. />ls -al /usr/bin/ksh -r-xr-xr-x 5 bin bin 237420 Apr 10 2007 /usr/bin/ksh /> I recently started working for a new employer. I have written UNIX K-Shell scripts for many years and have never had this particular issue before. Its perplexing me. I have... (2 Replies)
Discussion started by: troym72
2 Replies

5. UNIX for Dummies Questions & Answers

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

6. UNIX for Advanced & Expert Users

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

7. Shell Programming and Scripting

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

8. UNIX for Dummies Questions & Answers

Expect "interact" fails when called from another script

So, I have an expect script (let's call it expect.exp) that takes 3 arguments. It logs into a remote server, runs a set of commands, then hands control over to the user by the "interact" command. If I call this script from the command line, it works properly. Now I'd like to apply this script... (2 Replies)
Discussion started by: treesloth
2 Replies

9. Shell Programming and Scripting

"help me!!" if and function problems

I am trying to allow the user to be notified that the id has already taken from the file "record" and that the user has to contain a numerical figure as well. however when i run it, it will only stay at the please enter a number section and does not change. do u know where is the problem? ... (2 Replies)
Discussion started by: bassmasta1
2 Replies

10. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies
IMLS(1p)						     Internet Message commands							  IMLS(1p)

NAME
imls - list up the contents of the folder SYNOPSIS
imls [OPTIONS] [FOLDER] [RANGE] DESCRIPTION
The imls command produces a one line per message listing of the specified folder or mail/news messages. This command is provided by IM (Internet Message). OPTIONS
-s, --src=FOLDER,FOLDER... Folder name. Default value is "+inbox". "--src=+xxx" is equivalent to "+xxx". -f, --form=STRING Scan format. Default value is "%+5n %m%d %-14A %S || %b". -b, --buffer={on,off} Make output data buffered. -j, --jissafe={on,off} Safe manner for JIS. Default value is "on". -w, --width=NUM Width of result for scan listings. Default value is 80. -t, --thread={on,off} Make threads. -i, --indent=NUM Width of thread indent. Default value is 2. -g, --grep=STRING Grep pattern for vscan. -n, --namazu={on,off} Use namazu for vscan. -c, --casefold={on,off} Case sensitivity. Default value is "on". (This option affects both fieldname and pattern.) -d, --delimiter=STRING Mail header delimiter. Default value is " | ---- ". -D, --dupchecktarget=STRING Duplicate check target ('none', 'message-id', or 'message-id+subject'). Default value is "message-id". -x, --mimedecodequoted={on,off} Decode broken mime-encoded strings. -S, --sshserver=SERVER SSH port relay server. -q, --quiet={on,off} Do not show any messages. -v, --verbose={on,off} Print verbose messages when running. --debug=DEBUG_OPTION Print debug messages when running. -h, --help Display help message and exit. --version Output version information and exit. COPYRIGHT
IM (Internet Message) is copyrighted by IM developing team. You can redistribute it and/or modify it under the modified BSD license. See the copyright file for more details. IM151 2011-05-25 IMLS(1p)
All times are GMT -4. The time now is 06:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy