1
#!/bin/sh
unset foo
(: ${foo%%bar}) 2> /dev/null
E1="$?"

I know foo is a variable, ${foo%%bar} means remove last bar in $foo.
But what does (: ) mean there ?

I'm new to shell, can any one help me? Thanks!

gn cavalry
  • 149
  • 2
  • 11
  • 1
    @anubhava this snippet is part of a function that checks for a sane shell. See https://github.com/FFmpeg/FFmpeg/blob/master/configure#L17. unset makes sure that foo isn't defined. – Gyan Aug 03 '17 at 14:35

2 Answers2

0

http://tldp.org/LDP/abs/html/special-chars.html

In combination with the >> redirection operator, has no effect on a pre-existing target file (: >> target_file). If the file did not previously exist, creates it.

Riban
  • 26
  • 4
0

In bash, : means true.

Try :

: && echo ok; true && echo ok; : || echo ok; true || echo ok
Setop
  • 2,262
  • 13
  • 28