Sponsored Content
Top Forums Shell Programming and Scripting BASH: variable and function scope and subscripts Post 302858981 by cero on Wednesday 2nd of October 2013 04:43:12 AM
Old 10-02-2013
This is not completely correct:
"When a script is called by executing the file, it is executed in the shell of the caller. (not sure how to check this)"

Not sure what you mean with "called by executing the file", but unless you source it a script starts a subshell which terminates when the script ends. That's why functions and variables are not defined after execution (see jims post).
This User Gave Thanks to cero For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

$0 scope in function and calling script

Hi folks, I'm just running through an oreilly korn shell book but have witnessed an output difference on my own unix machine and the output provided in the book. Can anyone help? create a script called ascript as follows: function afunc { print in function $0: $1 $2 var1="in... (16 Replies)
Discussion started by: beckett
16 Replies

2. Shell Programming and Scripting

Bash: how to call function having it's name in variable?

Hello. Looking for a method of modularizing my bash script, I am stuck with such a problem. For example, I have: MODULE_NAME="test" FUNCTION_NAME="run" How do I can a function with name test_run? (4 Replies)
Discussion started by: FractalizeR
4 Replies

3. Shell Programming and Scripting

scope of the variable - Naga

Hi All, I am new to unix shell scripting, in the below script "num" is an input file which contains a series of numbers example : 2 3 5 8 I want to add the above all numbers and want the result finally outside the while loop. it prints the value zero instead of the actual expected... (13 Replies)
Discussion started by: nagnatar
13 Replies

4. Shell Programming and Scripting

variable scope

Hi, I want to know about the variable scope in shell script. How can we use the script argument inside the function? fn () { echo $1 ## I want this argument should be the main script argument and not the funtion argument. } also are there any local,global types in shell script? if... (3 Replies)
Discussion started by: shellwell
3 Replies

5. Shell Programming and Scripting

Scope of exported function

Hi I'm hoping someone can tell me how to extend the scope of an exported function in the korn shell. I have written a function in a file that I dot in from my .kshrc file and it works fine. However I would like this function to be available to anyone in a certain group on the machine... (10 Replies)
Discussion started by: steadyonabix
10 Replies

6. UNIX for Dummies Questions & Answers

Bash loops and variable scope

Hi All, I've been researching this problem and I am pretty sure that the issue is related to the while loop and the piping. There are plenty of other threads about this issue that recommend removing the pipe and using redirection. However, I haven't been able to get it working using the ssh and... (1 Reply)
Discussion started by: 1skydive
1 Replies

7. Shell Programming and Scripting

Variable scope in bash

Hello! Before you "bash" me with - Not another post of this kind Please read on and you will understand my problem... I am using the below to extract a sum of the diskIO on a Solaris server. #!/bin/sh PATH=/usr/bin:/usr/sbin:/sbin; export PATH TEMP1="/tmp/raw-sar-output.txt$$"... (3 Replies)
Discussion started by: haaru
3 Replies

8. Programming

Variable Scope in Perl

I have to admit that i have not used Perl at all and this is a singular occasion where i have to patch an existing Perl script. I dearly hope i do not have to do it again for the next 15 years and therefore try to avoid having to learn the programming language in earnest. The OS is AIX 7.1, the... (2 Replies)
Discussion started by: bakunin
2 Replies

9. Shell Programming and Scripting

Bash function using variable in it syntax error

The below bash function uses multiple variables CODING, SAMPLE, SURVEY, andvariant in it. The user selects the cap function and details are displayed on the screen using the $SURVEY variable, the directory is changed to $SAMPLE and the samples.txt is opened so the user can select the sample to... (6 Replies)
Discussion started by: cmccabe
6 Replies

10. UNIX for Beginners Questions & Answers

Bash Variable scope - while loop while reading from a file

Cope sample1: test.sh i=0 echo " Outside loop i = $i " while do i=$(( $i + 1)) echo "Inside loop i = $i " done echo " Out of loop i is : $i " When run output : Outside loop i = 0 Inside loop i = 1 Inside loop i = 2 Inside loop i = 3 Inside loop i = 4 Inside loop i = 5 Inside... (8 Replies)
Discussion started by: Adarshreddy01
8 Replies
ALLEGRO(1)							       4.0.3								ALLEGRO(1)

NAME
allegro-config - script to get information about the installed version of Allegro SYNOPSIS
allegro-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--libs] [--cflags] [--static] [--shared] [--env] [release|debug|profile] DESCRIPTION
allegro-config is a tool that is used to configure to determine the compiler and linker flags that should be used to compile and link pro- grams that use the Allegro library. It is intended to be used on Unix systems instead of the simple "-lalleg" call. EXAMPLE
gcc -o mygame mygame.o `allegro-config --libs` allegro-config will insert arguments needed to link into the command line. OPTIONS
allegro-config accepts the following options: --version Print the currently installed version of Allegro on the standard output. --libs Print the linker flags that are necessary to link an Allegro program. --cflags Print the compiler flags that are necessary to compile an Allegro program. --prefix=PREFIX If specified, use PREFIX instead of the installation prefix that Allegro was built with when computing the output for the --cflags and --libs options. This option is also used for the exec prefix if --exec-prefix was not specified. This option must be specified before any --libs or --cflags options. --exec-prefix=PREFIX If specified, use PREFIX instead of the installation exec prefix that Allegro was built with when computing the output for the --cflags and --libs options. This option must be specified before any --libs or --cflags options. --static Like --libs, but always print the linker flags needed to get a statically linked executable. --shared Like --libs, but always print the linker flags needed to get an executable linked against shared libs. --env Print some needed environment variables in the way needed in shell scripts. Output may be loaded into your environment using BASH#> eval `allegro-config --env` release This will use the optimized Allegro library which you should use when you are compiling for a release. debug This will add extra debug info into your programs, useful to find out where your program crashed or simply to debug it (names of functions are seen). You may choose this option while developing a program. profile This may be used when you want to profile your program - i.e. measure the speeds of various function calls. SEE ALSO
allegro-dev-tools(1) The allegro info entry COPYRIGHT
This manual page was written by Eduard Bloch <blade@debian.org>, for the Debian GNU/Linux system (but may be used by others). It is heavily based on a similar manpage for gtk-config, written by Owen Taylor. His notice: Copyright (C) 1998 Owen Taylor Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, pro- vided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in sup- porting documentation. Version 8 June 2003 ALLEGRO(1)
All times are GMT -4. The time now is 11:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy