Languages and Scripting
cancel
Showing results for 
Search instead for 
Did you mean: 

Difference between $( <cmd> ) and `<cmd>` - FOLLOWUP

 
Highlighted
Bob_Vance
Esteemed Contributor

Difference between $( <cmd> ) and `<cmd>` - FOLLOWUP

Just wanted to follow up on the previous thread:

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=833315&admit=716493758+1110888850877+28353475

The HP Posix shell behavior is interesting.
'bash', which is a superset of the Posix shell, does *not* behave the same way:


hpux1 ## echo $(cat <<-"EOF"
'NLS_CHARACTERSET'
EOF
)
"NLS_CHARACTERSET"


linux1 ## echo $(cat <<-"EOF"
'NLS_CHARACTERSET'
EOF
)
'NLS_CHARACTERSET'


Also, 'ksh' has the same behavior as 'sh' on HPUX (hard-to-soft change), while, on Linux, 'ksh' behaves the same as 'bash'.

I'm wondering which is "correct".
However, I can see no reason to change the hard quotes to soft, so I would lean toward 'bash's interpretation.


bv
"The lyf so short, the craft so long to lerne." - Chaucer
8 REPLIES 8
Highlighted
Steven E. Protter
Exalted Contributor

Re: Difference between $( <cmd> ) and `<cmd>` - FOLLOWUP

Very interesting.

I missed the first thread.

I though bash was supposed to be a posix compliant shell.

HP-UX's default shell is posix and ksh is supposed to be almost exactly the same as posix.

I would tend to think if something was wrong, or perhaps the better word is non-compliant, it would be Linux.

They added some enhancements to cron that were never accepted by the proprietary Unix community. Thats just an example.

Maybe just a bug.

I'd suggest linking these two threads into a Linux bugzilla report and see if you get a satisfactory explanation.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Highlighted
Bob_Vance
Esteemed Contributor

Re: Difference between $( <cmd> ) and `<cmd>` - FOLLOWUP

I once had a discussion with the bash maintainer about another HP Posix shell difference in the past. I was thinking of sending this his way to see what he has to say.

Again, I can see no reason for changing the ' to " as HP does.

bv
"The lyf so short, the craft so long to lerne." - Chaucer
Highlighted
c_51
Trusted Contributor

Re: Difference between $( <cmd> ) and `<cmd>` - FOLLOWUP

as a bit more information,

hp, solaris, and aix all have the same behavior, while linux is different.
Highlighted
Bob_Vance
Esteemed Contributor

Re: Difference between $( <cmd> ) and `<cmd>` - FOLLOWUP

>HPUX,Solaris,AIX

Well, that *is* interesting.
I wonder what in the world would be the reason for that behavior?!?!?

bv
"The lyf so short, the craft so long to lerne." - Chaucer
Highlighted
Bob_Vance
Esteemed Contributor

Re: Difference between $( <cmd> ) and `<cmd>` - FOLLOWUP

Reading the Posix shell spec, it's clear that HPUX Posix shell is wrong.

I discussed this with the 'bash' maintainer. It turns out that this is a bug in ksh88 which was fixed in ksh93. The "posix shell" in hpux, aix, and solaris are based on ksh88.

Indeed, in ksh on HPUX, the version is still
"Version 11/16/88"
.

Seems strange that this bug would persist this long.

I hope that some HPer out there might carry this "inside" ?


bv
"The lyf so short, the craft so long to lerne." - Chaucer
Highlighted
Alessandro Pilati
Esteemed Contributor

Re: Difference between $( <cmd> ) and `<cmd>` - FOLLOWUP

Bob,
interesting question.
Only for information, have a look also to this reference document about shells:

http://bcebhagalpur.net/tutorials/shell/shell.htm

http://www.kornshell.com/doc/faq.html

Cheers,
Alex
if you don't try, you'll never know if you are able to
Highlighted
Bob_Vance
Esteemed Contributor

Re: Difference between $( <cmd> ) and `<cmd>` - FOLLOWUP

Thanks, Alex!

bv
"The lyf so short, the craft so long to lerne." - Chaucer
Highlighted
Dennis Handly
Acclaimed Contributor

Re: Difference between $( <cmd> ) and `<cmd>` - FOLLOWUP

>wanted to follow up on the previous thread:

http://h30499.www3.hp.com/t5/Languages-and-Scripting/Difference-between-lt-command-gt-and-lt-command-gt/m-p/4890778

 

>I hope that some HPer out there might carry this "inside"?

 

Well, it looks like nothing has changed for 11.31, even though it is Unix 2003 branded.

 

Looking at tusc, shows the double quotes being written to the sh###.1 temp file.  So it is bad before cat(1) reads it and echo echoes it.