Suponho que você tenha set -e ou equivalente no script, portanto, ele será encerrado se um comando falhar.
Agora isso é unidiomático:
some command
if [ $? -eq 0 ]; then ...
É uma forma desnecessariamente indireta de fazer:
if some command; then ...
Um comando na parte de teste de uma instrução if não aciona set -e se falhar, porque isso invalidaria o ponto da instrução if .
De os documentos do Bash para -e :
The shell does not exit if the command that fails is part of the command list immediately following a
whileoruntilkeyword, part of the test in anifstatement, part of any command executed in a&&or||list except the command following the final&&or||, any command in a pipeline but the last, or if the command’s return status is being inverted with!.
Então, se você fizer isso:
if qmicli -d /dev/cdc-wdm0 --nas-get-serving-system | grep "'registered'"; then
#do stuff
fi
qmicli failing não acionará set -e .
(Além disso, não acho que haja qmicli de falha causando o problema - é qmicli falhando de forma a fazer com que o comando grep falhe, causando o problema.)