Sponsored Content
Top Forums UNIX for Advanced & Expert Users Dot sourcing differences in ksh, AIX vs Linux vs Solaris Post 302887296 by charles_n_may on Thursday 6th of February 2014 04:57:38 PM
Old 02-06-2014
RedHat

I want the behavior given by using the function keyword as it is indeed different from that using the parentheses. I use the difference (ksh functions defined with function have their own function environment and my code relies heavily on that isolation, particularly for logging the name of the function, $0, being called), and I am not really interested in bash compatibility.

However I did notice that if I use corrected bash syntax I get basic compatibility with the Solaris test (regardless of whether the curly brace is on the same line as the parens):

Code:
$ cat MyFun
#! /bin/ksh
print -- "In file MyFun, before def of function MyFun. PID=$$, system=$( uname -rsv )"
MyFun() {
print -- "In function MyFun. PID=$$, system=$( uname -rsv )"
return $(( $# % 128 )) #number of arguments mod 128
}
print -- "In file MyFun, after def of function MyFun. PID=$$, system=$( uname -rsv )"

Running the above in Linux:
Code:
$ . MyFun
In file MyFun, before def of function MyFun. PID=37604, system=Linux 2.6.32-220.el6.x86_64 #1 SMP Wed Nov 9 08:03:13 EST 2011
In file MyFun, after def of function MyFun. PID=37604, system=Linux 2.6.32-220.el6.x86_64 #1 SMP Wed Nov 9 08:03:13 EST 2011
$ MyFun
In function MyFun. PID=37604, system=Linux 2.6.32-220.el6.x86_64 #1 SMP Wed Nov 9 08:03:13 EST 2011
$ . MyFun
In file MyFun, before def of function MyFun. PID=37604, system=Linux 2.6.32-220.el6.x86_64 #1 SMP Wed Nov 9 08:03:13 EST 2011
In file MyFun, after def of function MyFun. PID=37604, system=Linux 2.6.32-220.el6.x86_64 #1 SMP Wed Nov 9 08:03:13 EST 2011

The above still isn't acceptable because using the bash sytax, the function's name is not stored in $0 inside the function body when it executes.

Last edited by charles_n_may; 02-06-2014 at 06:16 PM..
 

10 More Discussions You Might Find Interesting

1. BSD

OpenBSD sh and ksh differences?

Hi, I am running OpenBSD 3.7, my first attempt with this OS. I noticed that both /bin/sh and /bin/ksh are both really the pdksh. Yet each has its own manpage. I was wondering what are the differences b/w the two programs on OpenBSD. I.e., has the team configured pdksh to function one way if... (3 Replies)
Discussion started by: hadarot
3 Replies

2. UNIX for Dummies Questions & Answers

Major differences between AIX, Solaris, HP-UX, Linux

Hi All, I want to know the OS level differences between AIX, Solaris, HP-UX, Linux Apart from the vendor, H/w and command differences, any other significant points. regards, guru Charan (9 Replies)
Discussion started by: gurukottur
9 Replies

3. UNIX for Dummies Questions & Answers

script sourcing problem (ksh)

I have a script "abc.sh" in /tmp which has exit 0 as its last line when I run this script from /tmp/xyz/def.sh script as . ../abc.sh then the script executes but the control doesn't return to def.sh script for subsequent commands in def.sh but if I invoke the abc.sh from inside the... (3 Replies)
Discussion started by: rakeshou
3 Replies

4. UNIX for Dummies Questions & Answers

Guide to differences between Solaris and AIX

I've been more used to Solaris, but am now working on an IBM AIX box, P650 Certain commands like "top" are no longer available. Any ideas on where I can find help on this matter? Christopher Freville Alberquerque, NM (6 Replies)
Discussion started by: Solariums
6 Replies

5. Solaris

rootsh on Solaris 10 is not sourcing root's .profile

I'm attempting to setup rootsh on Solaris 10 to log the activity of users who require root access. However it does not appear to be sourcing root's .profile file even when run with the '-i' option. I was wondering if anybody else has run into this and might have a solution. Thank you. (9 Replies)
Discussion started by: kungfusnwbrdr
9 Replies

6. AIX

Aix process CPU differences.

Hi, I'm trying to create a script to catch a process which is consuming high CPU which I have pretty much done but it's just finding the correct place to pull the current CPU for that process. When viewed in Topas it's consuming 99.*% cpu But if I try using ps avg or ps -eo pcpu ... (5 Replies)
Discussion started by: elmesy
5 Replies

7. Shell Programming and Scripting

ksh script migration from Solaris to Linux.

We are migrating some scripts (ksh) from Solaris 10 to Linux 2.6.32. Can someone share list of changes i need to take care for this ? Have found few of them but i am looking for a exhaustive list. Thanks. (6 Replies)
Discussion started by: Shivdatta
6 Replies

8. Shell Programming and Scripting

Manipulating field differences using ksh

I have a list of files that should contain the following Im trying to find the items of interest that are missing from each file and create a csv. cat *.txt | while read file do grep 3500 file | tr '\012' ',' done My problem is this possible output one.txt ... (2 Replies)
Discussion started by: popeye
2 Replies

9. Shell Programming and Scripting

Sourcing Env file with eval works with ksh but not BASH

Hi, I am running this on Redhat 5.10 I have a simple test script called test.sh which has the following contents and it uses the BASH shebang. ------------------------------------------------------------- #!/bin/bash eval `/tmp/filereader.pl /tmp/envfile.txt` echo "TESTPATH=$TESTPATH" ... (28 Replies)
Discussion started by: waavman
28 Replies

10. Shell Programming and Scripting

ksh / AIX - Differences between lists to a text file

This seems pretty simple, but I cant figure it out. I get stumped on the simple things. I am running two commands 1) take a listing a directory of files, and filter out the doc_name (which is in a series of extracted files), and place it in a file. ls -l | awk '{print $9}' | grep... (5 Replies)
Discussion started by: jeffs42885
5 Replies
GRUB-RENDER-LABEL(1)                                               User Commands                                              GRUB-RENDER-LABEL(1)

NAME
grub-render-label - generate a .disk_label for Apple Macs. SYNOPSIS
grub-render-label [OPTION...] [OPTIONS] DESCRIPTION
Render Apple .disk_label. -b, --bgcolor=COLOR use COLOR for background -c, --color=COLOR use COLOR for text -f, --font=FILE use FILE as font (PF2). -i, --input=FILE read text from FILE. -o, --output=FILE set output filename. Default is STDOUT -t, --text=STRING set the label to render -v, --verbose print verbose messages. -?, --help give this help list --usage give a short usage message -V, --version print program version Mandatory or optional arguments to long options are also mandatory or optional for any corresponding short options. REPORTING BUGS
Report bugs to <bug-grub@gnu.org>. SEE ALSO
The full documentation for grub-render-label is maintained as a Texinfo manual. If the info and grub-render-label programs are properly installed at your site, the command info grub-render-label should give you access to the complete manual. grub-render-label (GRUB) 2.02-2ubuntu8.3 July 2018 GRUB-RENDER-LABEL(1)
All times are GMT -4. The time now is 01:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy