Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P10017
(An Untitled Masterwork)
Active
Public
Actions
Authored by
jbond
on Dec 30 2019, 10:45 AM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Referenced Files
F31494551: raw.txt
Dec 30 2019, 10:45 AM
2019-12-30 10:45:56 (UTC+0)
Subscribers
None
$ cat t.sh
#=!/bin/sh
set
-x
FETCH_HEAD_OR_EMPTY
=
$(
[
-z
"
${
1
:-
}
"
]
||
echo
FETCH_HEAD
)
printf
'HERE %s\n'
"
${
FETCH_HEAD_OR_EMPTY
}
"
FETCH_HEAD_OR_EMPTY
=
${
1
:-
FETCH_HEAD
}
printf
'HERE %s\n'
"
${
FETCH_HEAD_OR_EMPTY
}
"
$ ./t.sh
+
[
-z
]
+
FETCH_HEAD_OR_EMPTY
=
+
printf
HERE %s
\n
HERE
+
FETCH_HEAD_OR_EMPTY
=
FETCH_HEAD
+
printf
HERE %s
\n
FETCH_HEAD
HERE FETCH_HEAD
$ ./t.sh foo
+
[
-z foo
]
+
echo
FETCH_HEAD
+
FETCH_HEAD_OR_EMPTY
=
FETCH_HEAD
+
printf
HERE %s
\n
FETCH_HEAD
HERE FETCH_HEAD
+
FETCH_HEAD_OR_EMPTY
=
foo
+
printf
HERE %s
\n
foo
HERE foo
Event Timeline
jbond
created this paste.
Dec 30 2019, 10:45 AM
2019-12-30 10:45:56 (UTC+0)
Log In to Comment