You are not logged in.

#1 2015-05-13 08:09:36

demosnail
Member
Registered: 2015-05-13
Posts: 2

i met some questions with shell program "${SHELL:-/bin/sh} << 'marcin"

i made a timing project with command `at` in red hat linux 7.0,when this is done,there comes a file at path of /var/spool/at,the file reads like this:

define a lot of variables………………………………
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin; export PATH
PWD=/var/spool/at; export PWD
LANG=en_US.utf8; export LANG
SELINUX_LEVEL_REQUESTED=; export SELINUX_LEVEL_REQUESTED
HISTCONTROL=ignoredups; export HISTCONTROL
SHLVL=1; export SHLVL
HOME=/root; export HOME
LOGNAME=root; export LOGNAME
SSH_CONNECTION=10.192.180.19\ 62187\ 10.192.180.200\ 22; export SSH_CONNECTION
LESSOPEN=\|\|/usr/bin/lesspipe.sh\ %s; export LESSOPEN
XDG_RUNTIME_DIR=/run/user/0; export XDG_RUNTIME_DIR
OLDPWD=/var/spool/at/spool; export OLDPWD
cd /var/spool/at || {
         echo 'Execution directory inaccessible' >&2
         exit 1
}
${SHELL:-/bin/sh} << 'marcinDELIMITER089beff3'
echo "this"

marcinDELIMITER089beff3



i donot understand the "${SHELL:-/bin/sh} << 'marcinDELIMITER089beff3'" means,i never meet shell syntax like this .can some masters give me some explaination about this.
thanks very much!!

Offline

#2 2015-05-13 08:23:41

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: i met some questions with shell program "${SHELL:-/bin/sh} << 'marcin"

Please use code tags when pasting to the boards: https://wiki.archlinux.org/index.php/Fo … s_and_code


${SHELL:-/bin/sh}

is an example of parameter expansion, where if the parameter is unset or null, ie., $SHELL, then use /bin/sh.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2015-05-13 08:24:19

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,720

Re: i met some questions with shell program "${SHELL:-/bin/sh} << 'marcin"

It's a substitution, it checks if the env-variable SHELL is existing and if so, uses its content otherwise it falls back to the generic /bin/sh path. and << means you are providing the string afterwards as input

http://mywiki.wooledge.org/BashGuide/Pa … _Expansion for other examples

Edit: Jasonwryaaaaaaaaan *angry fist shake* wink

Last edited by V1del (2015-05-13 08:25:54)

Offline

#4 2015-05-13 08:46:09

demosnail
Member
Registered: 2015-05-13
Posts: 2

Re: i met some questions with shell program "${SHELL:-/bin/sh} << 'marcin"

V1del wrote:

It's a substitution, it checks if the env-variable SHELL is existing and if so, uses its content otherwise it falls back to the generic /bin/sh path. and << means you are providing the string afterwards as input

http://mywiki.wooledge.org/BashGuide/Pa … _Expansion for other examples

Edit: Jasonwryaaaaaaaaan *angry fist shake* wink



thanks very much,you remind me the syntax , i checked the book find the exact answer like this kind of syntax

Offline

#5 2015-05-13 09:34:13

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,858
Website

Re: i met some questions with shell program "${SHELL:-/bin/sh} << 'marcin"

demosnail wrote:

i made a timing project with command `at` in red hat linux 7.0

If you are using Red Hat, then you should direct your queries to their support community.

https://wiki.archlinux.org/index.php/Fo … pport_ONLY

However, since this is a distro-agnostic question and has already been answered, I will leave this topic in place. Please remember to mark your topic as solved.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Online

Board footer

Powered by FluxBB