What is /bin/true?

后端 未结 6 945
谎友^
谎友^ 2020-12-24 00:29

On a Linux system, what is /bin/true? What is it used for?

6条回答
  •  萌比男神i
    2020-12-24 00:50

    Note, it's not just silly or visually nice. It helps for example to exit a program without activating the end handlers which might mess up when doing multi threading or forked programs. Like in perl:

    #!/usr/bin/env perl
    
    exec "/bin/true";
    
    END {
      print "This wont get printed .. would have if I just 'exit' or 'die'\n";
    }
    

提交回复
热议问题