linux - "&>>" in sh behaves differently in Ubuntu 16.04.2 and Fedora 24 -


consider following sh command:

sh -c 'sleep 3 &>> /dev/null' 

&>> supposed redirect stdout , stderr. however, interpreted differently in fedora 24 , ubuntu 16.04.2.

in fedora 24, works in way, , command above waits until sleep ends.

in ubuntu 16.04.2, command runs sleep 3 & >> /dev/null, is, sleep sent background , command exits immediately.

the difference causes weired problems , cannot found since call things foo arg1 arg2 output_file &>> test.log in r script , expect command ends output_file written. in fedora 24, works expected surprise behavior changes in ubuntu 16.04.2.

i'm not sure if documented behavior.

the last link explains how fix dash (the sh in ubuntu):

sh -c 'sleep 3 > /dev/null 2>&1' 

this work in bash. note single > - don't need use append operator (>>) /dev/null.

tip: seeing might tempting write scripts compatible both implementations of sh, you'll make life unnecessarily difficult. use most powerful shell can expect available default on platforms you're interested in. in case bash (version 4), default on many other distros.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -