Sponsored Content
Top Forums Shell Programming and Scripting Shell quoting rules for other languages programmers Post 302715553 by wyderkat on Monday 15th of October 2012 05:44:29 AM
Old 10-15-2012
Shell quoting rules for other languages programmers

I've seen so many times that programmers were confused about shell quoting and white spaces interpretation, that I decided to investigate that problem deeper. And my conclusion is that quoting in shells is very different from other programming languages. Programmers who have bigger experience in C/Python/Java/PHP than in Shell should remember about two unintuitive rules:
  • everything in shell is a string, and one need to quote everything properly. Also when reading variables: "$X", not only storing X="hi there"
  • shell will parse lines of code just one time, leaving unresolved nested variables and commands. In this case programmer need to explicitly use "eval" function.

I've written short article about this if anyone will be more curious you can find it under "white shell cofoh"
This User Gave Thanks to wyderkat For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX Desktop Questions & Answers

Shell scripting & programming languages

If I want to do high-end 3d animation, what skell scripting languages, and programming languages shoul I learn? If you know any good resources for learning these languages they would be appreciated. (1 Reply)
Discussion started by: aloysius1001
1 Replies

2. UNIX for Advanced & Expert Users

Perl - Programmers manual online?

I have never programmed in Perl (insert laughter, mock, etc. here ____) - so I need a sort of "Programming in Perl" covering the basics. I now have two Perl books, one is a 5 volume Unix resource kit, the other is "Mastering algorithms with Perl" - none of them explains how to produce "hello,... (11 Replies)
Discussion started by: AtleRamsli
11 Replies

3. News, Links, Events and Announcements

Good Essays For Programmers

Check the essays out. http://www.paulgraham.com (0 Replies)
Discussion started by: photon
0 Replies

4. What is on Your Mind?

Suggested venues to look for advanced C programmers

Can someone suggest any online venues to assist in recruiting a senior C programmer (looking for someone interested in working on kerberos code). I've tried a bunch of the open source and higher ed lists (this is for Univ. of Michigan). The commercial services such as Dice or monster yield a... (7 Replies)
Discussion started by: painman
7 Replies

5. What is on Your Mind?

Programming languages polyglots: how many languages you know?

Post what languages (including scripting) you know, why and where you think that language is most usable. Also include libraries in which you're really good at (libusb, gtk, qt, etc). assembly? C or C++? perl or python? pascal? bash or csh/tcsh? opengl? gtk or qt? mono? (27 Replies)
Discussion started by: redoubtable
27 Replies

6. Shell Programming and Scripting

Shell quoting problem while editing a remote file using sed

value of i = solarisbox ssh $i "cat /etc/hosts | sed "s/$i\.local\.//" | sed "s/$i\./$i/" | sed "s/$i/$i.sol.com/" > /usr/users/chidori/edit_hosts"While running the above one liner its i am not able to make the changes and write it to the file /usr/users/chidori/edit_hosts . I know there is a... (2 Replies)
Discussion started by: chidori
2 Replies

7. Programming

Hello UNIX programmers

i have MOTIF installed X11 a easy program is saved as hello.c there is the following message where can i get the X11/intrinsic.h , file ??? need help to compile my system : MX-16 Linux Debian Jessie / i386 hans@mx1:~/Documents $ cc push.c -o push -lXm -lXt -lX11 In file included from... (0 Replies)
Discussion started by: Zabo
0 Replies

8. Forum Support Area for Unregistered Users & Account Problems

Trojan is detected when I visit Programmers forum

When I visit Programmers forum my ESET Nod32 detects TrojanDownloader.Pegel.BH.trojan I don't know when it started, as I visited the site today after staying off-line a few days. (2 Replies)
Discussion started by: migurus
2 Replies

9. What is on Your Mind?

Multics Systems Programmers Manual as of 1969-04-01, comprising 996 PDF Files

While working on my current "UNIX history project" I ran across this: Jerry Saltzer created an online scanned copy of the Multics Systems Programmers' Manual (MSPM) in this directory. Based on the 1969-04-01 MSPM, the repo comprising 996 PDF files. In order to help preserver the MSPM, ... (1 Reply)
Discussion started by: Neo
1 Replies

10. What is on Your Mind?

The poorest of computer users are programmers...

Hi guys and gals... A mildly humourous blog from 2013, but I come into this category... ;oDD Languager: The Poorest Computer Users are Programmers (0 Replies)
Discussion started by: wisecracker
0 Replies
msh(1mh)																  msh(1mh)

Name
       msh - MH shell

Syntax
       msh [ -help ] [ -prompt string ] [ file ]

Description
       The command is an interactive program that implements a subset of the normal MH commands operating on a single file in format.  That is, is
       used to read a file that contains a number of messages, as opposed to the standard MH style of reading a number of files, each file being a
       separate message in a folder.

       The chief advantage of is that, unlike the normal MH style, it allows a file to have more than one message in it.  In addition, can be used
       on other files, such as message archives which have been packed using

       When invoked, reads the named file, and enters a command loop.  You can type most of the normal MH commands.  The syntax and  semantics	of
       these  commands	typed to are identical to their MH counterparts.  In cases where the nature of would be inconsistent with the way MH works
       (for example, specifying a +folder with some commands), will duly inform you.  The commands that currently supports are:
       ali	burst	 comp	 dist	  folder
       forw	inc	 mark	 mhmail   msgchk
       next	packf	 pick	 prev	  refile
       repl	rmm	 scan	 send	  show
       sortm	whatnow  whom

       In addition, has a command which gives a brief overview of all the options.  To terminate either type <CTRL/D>, or use the command.  If the
       file is writable and has been modified, then using will ask you if the file should be updated.

       A redirection facility is supported by Commands may be followed by one of the following standard ULTRIX symbols:

       |	 Open an interprocess channel; connect output to another ULTRIX command.

       >	 Write output to file.

       >>	 Append output to file.

       If file starts with a tilde (~), then a C-shell-like expansion takes place.  Note that commands are interpreted by

       When  parsing  commands	to the left of any redirection symbol, will honor the backslash () as the quote next-character symbol, and double
       quotes (") as quote-word delimiters.  All other input tokens are separated by white space (spaces and tabs).

       You may wish to use an alternative profile for the commands that executes; see for details of the $MH environment variable.

Options
       -help	 Prints a list of the valid options for this command.

       -prompt string
		 Sets the prompt for If the string you specify includes white space, you must enclose it in double quotes  (").   If  you  do  not
		 specify this option, the default prompt is (msh).

       The following defaults are used by

	      file defaults to
	      -prompt (msh)

Restrictions
       The  shell  is  not the C-shell, and a lot of the facilities provided by the latter are not present in the former.  In particular, does not
       support back-quoting, history substitutions, variable substitutions, or alias substitutions.

       does not understand back-quoting.  The only effective way to use inside is to always use the -seq select option.  If you add the  following
       line to your will work equally well from both the shell and
       pick: -seq select -list

       There is a strict limit of messages per file in format which can handle.  Usually, this limit is 1000 messages.

Profile Components
       Path:	      To determine your Mail directory
       Msg-Protect:   To set protections when creating a new file
       fileproc:      Program to file messages
       showproc:      Program to show messages

Files
       The user profile.

       The system customization file.

See Also
       csh(1), packf(1mh), sh(1), mh_profile(5mh)

																	  msh(1mh)
All times are GMT -4. The time now is 03:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy