The Bourne shell is a historical implementation of /bin/sh

learn more… | top users | synonyms

2
votes
1answer
66 views

Getting script's real absolute path in /bin/sh

I'm looking for a way to get the real absolute path to the current /bin/sh script. It should work for situations like this one: /path/to/symlink/in/PATH/somescript -> ../../Package/current/...
4
votes
2answers
363 views

SH: How to make vars from one script available in the main script?

I have two scripts that need to run and both require the same variables set the same way. As a result I figured I'd break the setting of the variables out into a separate script. However, I can't seem ...
0
votes
1answer
199 views

syntax error: invalid arithmetic operator (error token is “.c”)

I am trying to test if file "file1.c" is present in the current working directory, what am I doing wrong with my test command? I thought I understood this command, am I doing something wrong for the ...
1
vote
3answers
204 views

How to break a long string into multiple lines in the prompt of read -p within the source code?

I am writing an installation script that will be run as /bin/sh. There is a line prompting for a file: read -p "goat can try change directory if cd fails to do so. Would you like to add this feature?...
1
vote
1answer
41 views

What does a “>|”-redirection (“greater-pipe”-redirection) mean? [duplicate]

What does the >|-redirection in bash do? I just found out, that echo text >| somefile creates the file somefile (if not existing yet), and fills it with text. Similar as echo text > somefile ...
0
votes
2answers
268 views

Bourne Shell to CShell

This works fine: #!/bin/sh ALTER="$1" NAME="$2" for pr in $(pgrep $NAME); do elapse=$(ps -o etime= -p $pr) [ "${elapse%:*}" -gt "$ALTER" ] && echo $pr done But if I try to switch ...
2
votes
0answers
26 views

When would you use $* instead of $@ in Bourne shells? [duplicate]

In Bourne shell and its offshoots like Bash, I believe the only difference between $* and $@ is that $@ expands in double quotes so that each argument ends up as a single word even if it contained ...
4
votes
1answer
74 views

“$@” expansion for user defined variables

I'm trying to get a (bourne shell) variable to expand like "$@" so it produces multiple words with some having preserved spaces. I've tried defining the variable in many different ways but still can't ...
1
vote
1answer
51 views

Bourne shell: ignoring certain kinds of stdin

I have a program that is currently working, but I need to modify it to ignore some stdin that is not fitting for its correct function. Right now, to run the program: printf "1\n3\n5\n" | sh prog The ...
1
vote
3answers
37 views

Bourne shell: trailing `-` operator in parameter substitution

Newbie here. I'm reading a shell script for adding a progress bar to certain processes (found here). I'm having trouble understanding this (optional) line: #BAR_EXT=${BAR_EXT-} The comment says ...
4
votes
1answer
1k views

Variable scope in while-read-loop on Solaris

Could someone please explain to me why my while loop seems to have an internal scope? I've seen multiple explanations online but they all have to do with pipes. My code has none. The code: #!/bin/...
18
votes
4answers
15k views

Arrays in Unix Bourne Shell

I am trying to use arrays in Bourne shell (/bin/sh). I found that the way to initialize array elements is: arr=(1 2 3) But it is encountering an error: syntax error at line 8: `arr=' unexpected ...
2
votes
0answers
82 views

What privileges do I have (find out within bourne shell script) [closed]

I am hacking away on a remote helper for git. The script is in bourne shell. I wanted to create some temporary directory in the home dir. For some reason I get permission denied. From my shell ...
19
votes
3answers
824 views

Use of ^ as a shell metacharacter

I wrote a small script today which contained grep -q ^local0 /etc/syslog.conf During review, a coworker suggested that ^local0 be quoted because ^ means "pipe" in the Bourne shell. Surprised by ...
7
votes
1answer
1k views

IFS null is not the same as unset IFS?

I read a great question on here called Understanding IFS. I was surprised because the answers and comments quote POSIX which states that IFS= is not the same as unsetting IFS. If you unset IFS, ...
5
votes
2answers
4k views

bourne shell if [ -e $directory/file.$suffix ]

I've been looking inclusive I even checked the if manual for bash and tried in cli mode. #!/bin/sh CONFIG_DIR="/var/opt/SUNWldm/" read option if [ $option -eq 9 ]; then ret=1 elif [ -e ${...