Also, use shellcheck. Incorporate it into you editor. Fix all warning and don’t ignore them. This will push you deep into bash syntax rabbit holes but you come out better the other side.
A lot of bash errors are not understanding possible cases due to white space.. which shellcheck catches. After using it for a while, I don’t even really worry about white space because of the good habits I’ve learned/(been forced to use).
The style issue shellcheck reports here is probably what we both suspect it is.
The call to echo has a likely purpose is to trim some spaces from a string, but it's not at all obvious why this is done or what the benefit is. In the best case, it leaves the reader pondering this weird semi-no-op.
If you think shellcheck, and probably most readers, is wrong in this assertion, just speak your mind and let's learn from one another. But I certainly can't guess your intention here.
Using "echo" at all is a problem. It's recommended to switch to "printf" instead as echo has unfixable problems, especially with strings that start with a dash.
cwingrav|2 years ago
ndsipa_pomu|2 years ago
(I can't actually recall encountering a filename that includes a linefeed)
blueflow|2 years ago
xorcist|2 years ago
The call to echo has a likely purpose is to trim some spaces from a string, but it's not at all obvious why this is done or what the benefit is. In the best case, it leaves the reader pondering this weird semi-no-op.
If you think shellcheck, and probably most readers, is wrong in this assertion, just speak your mind and let's learn from one another. But I certainly can't guess your intention here.
rascul|2 years ago
tr -dc A-Za-z0-9 </dev/urandom | dd count=1 bs=16 2>/dev/null; echo
A few less characters to type, you get your newline, and shellcheck doesn't complain.
ndsipa_pomu|2 years ago
saagarjha|2 years ago
rascul|2 years ago
https://github.com/bash-lsp/bash-language-server/
ndsipa_pomu|2 years ago