Hello,
This is not a problem specific question.
While surfing on google to find a solution for the latest error messages I have received from command line, I found some suggestions regarding usage of linux commands:
Could it be a problem specific comment or in most cases, `` causes issue?
Normally I have been using this though and did not encounter any issue.
How come would linux detect uppercase variables as path?
No.
The problem relates to nested `` , a pair of back-ticks inside another pair of back-ticks will cause errors.
It has nothing to do with PATH particularly. What if you made a variable called "BASH_REMATCH", what would happen? I picked this one because it does not come up very often here on the forums.
Answer: It is the name of an array. Your code could break regular expression searches in bash. None of the special variables bash uses are lowercase.
So, no matter what you do to lowercase variables, you will not mess up shell and other utilities do internally.
This is the output of the set command on my cygwin instance on Windows 7: It's BIG. Many,many variables. If
I use other than default software the variables may increase a lot - Oracle is an example.
Well Jim, it's nice to see that there are historical backticks in the output of set for things such as gawkpath_default
I must admit that I spent a few years writing awful code using backticks in my scripts and fighting with escapes and escaped escapes depending how many layers there were or if I was running things remotely. Compare these:-
Both are pretty awful and should probably have been replaced by something neater overall anyway, but the escaped back-ticks make it particularly horrible to decipher. Sadly I had to escape the $ to get that passed as literal test to the remote server so that it would then execute there. I'm not proud of it but it worked when we hardly knew what we were doing and so this sort of thing got used all over the place for a while, so deciphering it (and worse) became quite an effort. It is all tidied up/replaced now anyway. They are worse to understand if you are not the author because the scripts were rarely commented.
The really confusing part is trying to work out where a back-tick ends with all those escapes too. At least with the start of a call being $( and the end being ) you have a fighting chance and tools like vim can help you too because they recognise and highlight the 'other end' and a call.
I hope that this help (or my awful old-style code makes you squirm :o)
Robin
Bizarrely, I have switched from lowercase to uppercase for variables as they are easier to see straight away. The vast majority of tools/commands/utilities are lowercase and can _mingle_ with the variables visually whereas uppercase tend to stand out. I do pick names that are very literal and unlikely to coincide with those of the/any environment.
Examples: VERTICAL_GAIN and AUDIO_SAMPLE ...
On AudioScope I was _briefed_ about using back-ticks but they have long since gone, along with this, which is still valid on OSX 10.14.3's bash version, 3.2.57: x=1; x=$[ ( x + 4 ) ]; echo "$x"<CR> ...
With the possible exception of csh , tcsh and friends, which use variable names like path and then they will make changes to the environment variable like PATH automatically (as I recall).
But in terms of Bourne shell and descendants, I agree, and good point ... cheers, drl
You do not want to substitute any $-expression on the remote site by the calling site.
Then it is easier to use protective 'ticks' for the local site, so the remote side gets its contents unchanged. And have \' or " inside it that becomes ' or " on the remote side.
Yes, I said that even the better version was awful code :o and I'm having to remember it because it's long since replaced/retired. I might even have a syntax error, but I just remember the horror of all those escapes