O +
é o prompt PS4
. Defina-o como uma string vazia:
#!/bin/bash
PS4=''
set -x
echo 'This is a script that has debugging turned on'
Teste:
$ bash script.sh
echo 'This is a script that has debugging turned on'
This is a script that has debugging turned on
Ou, com o seu script original, defina PS4
como uma string vazia para o script ao invocá-lo:
$ PS4='' ./script.sh
echo This is a script that has debugging turned on
This is a script that has debugging turned on
Isso pode ser usado para inserir um timestamp:
$ PS4='$(date +"%T: ")' ./script.sh
21:08:19: echo 'This is a script that has debugging turned on'
This is a script that has debugging turned on
21:08:19: echo 'Now sleeping for 2 seconds'
Now sleeping for 2 seconds
21:08:19: sleep 2
21:08:21: echo Done
Done