- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Command substitution strange behavior?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2009 08:49 AM
тАО10-26-2009 08:49 AM
Command substitution strange behavior?
I have seen a strange behavior i HP-UX that sombody have to explain to mee??
If you try this scipt:
---------------------------------
RES=$(cat <
double "qoute"
single \'qoute\'
END
)
echo $RES
RES=`cat <
double "qoute"
single \'qoute\'
END
`
echo $RES
---------------------------------
In HP-UX the result is:
single "qoute" double "qoute" single \'qoute\'
single 'qoute' double "qoute" single \'qoute\'
But in linux bash it is ( as exspected) :
single 'qoute' double "qoute" single \'qoute\'
single 'qoute' double "qoute" single \'qoute\'
Why is there a diffrense in HP-UX between $() and `` ?
Regards Jesper
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2009 09:08 AM
тАО10-26-2009 09:08 AM
Re: Command substitution strange behavior?
First, the HP-UX Posix shell ('/usr/bin/sh' or '/sbin/sh') does differ from the 'bash' shell.
I can't offer a reason for the difference you see, however.
It is interesting, though, that if you do:
#!/usr/bin/sh
cat <
END
cat <
END
...you get the expected:
single 'qoute' double "qoute" single \'qoute\'
single 'qoute' double "qoute" single \'qoute\'
...
I'm not sure why you are resorting to collecting a here-doc in a variable and then echoing that variable.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2009 09:41 AM
тАО10-26-2009 09:41 AM
Re: Command substitution strange behavior?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2009 09:53 AM
тАО10-26-2009 09:53 AM
Re: Command substitution strange behavior?
I use the construction to run sqlplus from oracle and get the result in a variable.
Jesper
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2009 04:55 PM
тАО10-26-2009 04:55 PM
Re: Command substitution strange behavior?
The $() construct is always preferred for modern shells as it can provide unambiguous nesting and is infinitely easier to document properly. The reason is that ' and ` are very, very often typed incorrectly. Read the man page for sh-posix (HP-UX), ksh (any OS) and Bash (any OS) to see the deprecation (obsolete) of grave accents for command substitution.
Bottom line, there are differences between shells. I don't have a clear explanation for the changing of single quotes into double quotes. But as you might imagine, characters that special meaning to the shell will always need extra handling.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2009 05:08 PM
тАО10-26-2009 05:08 PM
Re: Command substitution strange behavior?
Check this out , similar bash WT... page:
you will find more interesting stuff,
http://almirkaric.com/tag/awk/
Hth,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2009 11:03 PM
тАО10-26-2009 11:03 PM
Re: Command substitution strange behavior?
I know all about shells.
I have worked vith HP-UX and other unixes for more than 15 years and been teathing HP-UX at HP.
That is why i do not understand the difference.
Regards Jesper
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2009 02:46 AM
тАО10-27-2009 02:46 AM
Re: Command substitution strange behavior?
It looks like a bug with new-fangled $() and here documents. Please report it to the Response Center.
RES=$(cat <
It fails even with: <<\END
If you do this, you see the here documented is messed up when it parses the $():
RES=$(cat <<\END > /dev/tty
single 'qoute'
double "qoute"
single \'qoute\'
END
)
>JRF: I can't offer a reason for the difference you see
It's broken. :-(
>It is interesting, though, that if you do:
That doesn't mix the gas with a match.
>Bill: characters that special meaning to the shell will always need extra handling.
And it failed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2009 06:11 AM
тАО10-27-2009 06:11 AM
Re: Command substitution strange behavior?
# more ./de.sh
#!/usr/dt/bin/dtksh
RES=$(cat <
double "qoute"
single \'qoute\'
END
)
echo $RES
RES=`cat <
double "qoute"
single \'qoute\'
END
`
echo $RES
# ./de.sh
single 'qoute' double "qoute" single \'qoute\'
single 'qoute' double "qoute" single \'qoute\'
Wonder if this is some obscure feature - the POSIX/IEEE standards are almost impossible for joe-admins like me to make sense of, but I wonder if there is something in there that might explain this behaviour...
HTH
Duncan
I am an HPE Employee