4
ln -s /var/log/$SERVICE_NAME $RPM_INSTALL_PREFIX/logs || :

In the rpm spec file every line ends with || :

What is the significance of the || : and why is it there?

5 Answers5

14

It causes any error to be ignored so that the rpm operation isn't canceled.

|| causes the next command to run if the previous command failed, and : always succeeds.

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
3

It swallows the exit code.

|| does the thing after it if the thing before it fails (i.e., has a non-zero exit code). : is the “do nothing” command. Put them together…

Donal Fellows
  • 133,037
  • 18
  • 149
  • 215
2
`||` is OR operator. `:` means "do nothing". 

Your statement says, "do the soft linking or do nothing"

pavium
  • 14,808
  • 4
  • 33
  • 50
bash-o-logist
  • 6,665
  • 1
  • 17
  • 14
2

I know others have answered, but I prefer to put:

command || /bin/true

IMHO that makes it a lot more obvious to the next person who is reading the bash script/spec file.

Aaron D. Marasco
  • 6,506
  • 3
  • 26
  • 39
1

It is simply means OR. You can try small testing like this

ls nofile-here-like || echo 'Not here'

If file not there echo will printed. Try with existing file, it will not

Senthil
  • 5,514
  • 2
  • 22
  • 11