All Questions
14 questions
3
votes
1
answer
93
views
How does my function break `functions`?
I wrote a ksh function for git checkout (I've removed some irrelevant proprietary components for the sake of the public question, if you're wondering why it's useful to me):
# Checkout quicker
...
2
votes
0
answers
91
views
Problem with ksh namespaces defined inside functions
I'm new to ksh namespaces. The problem I'm seeing is that if I define a namespace inside a function, then variables defined within that namespace clobber the same-named variables outside the namespace ...
1
vote
1
answer
852
views
How to list all function names only, one per line
In ksh93 typeset -f lists all functions and its definition.
$ f(){ :; }
$ typeset -f
f(){ :; }
With the added quirk that functions that have been defined without a trailing newline are listed the ...
1
vote
1
answer
2k
views
How to call sub function of a different function from current function in ksh?
In this is the scenario, need to call func1 from Main_Func. How do I call it?
Main_Func() {
<code>
}
Initialize_func() {
func1() {
<code>
}
}
4
votes
4
answers
107
views
Is it possible to use functions declared in a shell flavor in another shell type
I have a bash script that contains many common functions definitions for our Linux system.
Is it possible to source it and use functions from another shell flavor (csh and ksh) ?
0
votes
3
answers
3k
views
Get the name of the shell script from inside a function
Say I've got this:
#!/bin/sh
function show_help {
cat<<%
Usage: $0 [-h]
%
}
# the following lines is pseudo-code
if argument contains "-h"
show_help
otherwise
do_stuff
If I run ./test it ...
9
votes
2
answers
2k
views
Circular name references in bash shell function, but not in ksh
I'm writing a set of shell functions that I want to have working in both Bash and KornShell93, but with Bash I'm running into a "circular name reference" warning.
This is the essence of the problem:
...
7
votes
3
answers
2k
views
Checking if a command is a built-in in ksh
How can I check if a command is a built-in command for ksh?
In tcsh you can use where; in zsh and bash you can use type -a; and in some modern versions of ksh you can use whence -av.
What I want to ...
1
vote
1
answer
861
views
A basic function that doesn't work [duplicate]
I've tried several modifications to see why it's not working, but I can't find the answer.
Here is my code, this is in french but this is just a normal fonction that ask to the user if he's ready to ...
11
votes
3
answers
18k
views
Forward function and variables into sudo su - <user> <<EOF
I have declared functions and variables in bash/ksh and I need to forward them into sudo su - {user} << EOF:
#!/bin/bash
log_f() {
echo "LOG line: $@"
}
extVAR="yourName"
sudo su - <user&...
3
votes
1
answer
6k
views
set -xv behavior in ksh vs bash
Normally I like to have all of the debug output of a script go to a file, so I will have something like:
exec 2> somefile
set -xv
This work very will in bash, but I have noticed in ksh it behaves ...
0
votes
1
answer
117
views
Using variable in KSH function
I tried to have a switch if either an option is set or not
while getopts "s:u:d:e:ch" _OPTION; do
case $_OPTION in
...
c)
isCSet="Y"
then I'm ...
0
votes
1
answer
905
views
Function, return value using pwd in KSH
I tried to write a small ksh script:
fDestExists (){
cd /tmp
read vANSWER?" >> Do you want to create a repository in pwd ? Type YES or NO"
echo " |----> $(fGetDatum) You ...
47
votes
4
answers
43k
views
Executing user defined function in a find -exec call
I'm on Solaris 10 and I have tested the following with ksh (88), bash (3.00) and zsh (4.2.1).
The following code doesn't yield any result:
function foo {
echo "Hello World"
}
find somedir -exec ...