1

I'm running Ubuntu 18.04 LTS.

I figured out the terminal uses the .bashrc file. I added:

export PATH="/home/keaton/scripts/:$PATH"

to that file then created a script in the scripts directory. The simple script is:

echo "Hello World"
echo $(which neqn)
cat $(which neqn)

when I go into the terminal and run sh intro I get:

sh: 0: Can't open intro

I've triple checked that the path to the scripts directory is typed out correctly. Is there something I'm typing or configuring incorrectly?

1 Answer 1

1

Instead of using sh trying using bash. This works for me:

$ bash intro
Hello World
/usr/bin/neqn
#! /bin/sh
# Provision of this shell script should not be taken to imply that use of
# GNU eqn with groff -Tascii|-Tlatin1|-Tutf8|-Tcp1047 is supported.

GROFF_RUNTIME="${GROFF_BIN_PATH=/usr/bin}:"
PATH="$GROFF_RUNTIME$PATH"
export PATH
exec eqn -Tascii ${1+"$@"}

# eof

When you invoke your script using sh you're actually using bash but it's running in a mode which makes it behave as if it's a more ancient version of the shell that is the predecessor to Bash.

excerpt from man bash:
 If  bash  is  invoked  with the name sh, it tries to mimic the startup 
 behavior of historical versions of sh as closely as possible, while 
 conforming to the POSIX standard as well.  When invoked as an interactive 
 login shell, or a non-interactive shell with the --login option, it first 
 attempts to read and execute commands from /etc/profile and ~/.profile, 
 in that order. The  --noprofile option may be used to inhibit this 
 behavior.  When invoked as an interactive shell with the name sh, bash 
 looks for the variable ENV, expands its value if it is defined,
 and uses the expanded value as the name of a file to read and execute.  

 Since a shell invoked as sh does not attempt to read and execute  
 commands  from  any  other  startup  files,  the --rcfile  option  has no 
 effect.  A non-interactive shell invoked with the name sh does not 
 attempt to read any other startup files.  When invoked as sh, bash enters 
 posix mode after the startup files are read.
0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.