I am writing an error logging script where upon error, the erroneous line
and erroneous command are captured
But I don't know how to suppress logging error on some code where I redirect the error to /dev/null/ as below -
Sample code -
The trap is logging error line no. and the command for the above line when the files are not available. Is there a way to suppress the logging of the redirected errors?
The trap is logging error line no. and the command for the above line when the files are not available. Is there a way to suppress the logging of the redirected errors?
-P
In general, I agree with RudiC.
In the case above you are not actually using wildcards so ls should be producing one or zero files. Why not this instead?
If a wildcard is involved (perhaps in your script filename is set to, say, *.c), you could try this:
Note that this is a bashism that came from zsh so you would have to check if it works with your shell.