Portál AbcLinuxu, 10. května 2025 16:29
#!/bin/sh cat << LABEL #!/bin/sh A=10 B=5 sleep $((A/B)) LABEL
Řešení dotazu:
Na to není potřeba, aby v ní byla nula, stačí aby nebyla nastavená nebo aby v ní bylo něco, co není číslo:
mike@unicorn:~> unset B mike@unicorn:~> echo $[A / B] bash: A / B: division by 0 (error token is "B") mike@unicorn:~> B=xyz mike@unicorn:~> echo $[A / B] bash: A / B: division by 0 (error token is "B")
Viz bash(1)
:
Ifword
is unquoted, all lines of the here-document are subjected to parameter expansion, command substitution, and arithmetic expansion, the character sequence\<newline>
is ignored, and\
must be used to quote the characters\
,$
, and`
.
Takže by mělo stačit první řádek přepsat na
cat <<"LABEL"
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.