Często widziałem ten konstrukt w skryptach i sam go używałem, ale niepokoi mnie to, że nie mogę go znaleźć w dokumentacji.
Przykład:
[ -f file1 ] &&
[ -f file2 ] &&
echo "Both files exist." ||
echo "One or the other file doesn't exist."
Można to również zrobić za pomocą ukośników odwrotnych przed znakami nowej linii, jak wspomniano w man bash:
If a \<newline> pair appears, and the backslash is not
itself quoted, the \<newline> is treated as a line continuation (that
is, it is removed from the input stream and effectively ignored).
Przykład:
[ -f file1 ] && \
[ -f file2 ] && \
echo "Both files exist." || \
echo "One or the other file doesn't exist."
... ale to nie wydaje się konieczne. Pierwsza wersja powyżej działa nawet bez ukośników.
Gdzie mogę to znaleźć man bash? (Czy ta bashspecyfikacja jest zgodna z POSIX?)
;,&,(i).