Subject: RE: [xsl] [off-list] document(lang_*.xml) From: "Roger Glover" <glover_roger@xxxxxxxxx> Date: Sat, 25 Jan 2003 14:59:56 -0600 |
Mike Brown wrote: > Some shells have a 'noclobber' option that controls whether or > not '>' will overwrite an existing file or raise an error. How > you set this option depends on what shell you're using. > #!/bin/sh implies Bourne shell, In Posix-compliant systems (most modern UNIX variants, including all formulations of Linux I have used), it implies Korn shell. The original Bourne shell does not have a "noclobber" feature at all. > but on some Linux systems > they've replaced it with Bourne Again shell (bash), which was > not a good idea, in my opinion. I have seen Linux systems where the default user shell was bash, but it was still located in /bin/bash. Can you give an example of a Linux where /bin/sh is actually bash? > 'man sh' or 'man bash' will > give you all the details. Well... Err... Yeah, if you have time to read through a *novel* to find a particular paragraph. Here is the skinny. If you are using *either* bash or Korn shell, the noclobber feature is set with 'set -o noclobber' and unset with 'set +o noclobber'. That's right "-" sets the feature, and "+" unsets it. Ain't Unix grand!? Again, the *Bourne* shell has no noclobber feature, so you are out of luck if you are on some old system that actually still uses the Bourne shell. The C shell and variants use a different mechanism for noclobber, but if "#!/bin/sh" resolves to one of these your system is seriously broken. > Anyway... > > echo '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' > list.xml > echo '<LangList>' >> list.xml > ls lang_*.xml | sed -e "s@\(.*xml\)@<language>\1</language>@" >> list.xml > echo '</LangList>' >> list.xml > > Instead of 'ls', you might want to do '/bin/ls -1'. Many people create > personal aliases for 'ls' that change the list format. By explicitly > specifying /bin/ls, you avoid using the alias. The -1 forces the > output to be > one filename per line, in case the default on your system is multicolumn. Or you could just avoid local environment differences in Unix commands by not using any Unix commands at all: echo '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' > list.xml echo '<LangList>' >> list.xml for fileName in lang_*.xml do echo '<language>'"$fileName"'</language>' done >> list.xml echo '</LangList>' >> list.xml The only command used in this formulation is the "echo" command, which is usually a built-in command. But in any case, this syntax of the echo command works the same in every shell I have ever used. Someone *could* use an alias or shell function to define echo to do something different, but it would be terribly counterproductive. Every general purpose shell script they ever use would stop working correctly. ======================================================= It seems to me that this thread has wandered way off-topic. I only responded at all because there was incomplete or incorrect information here. I would be glad to discuss this in e-mail with anyone who wants to participate. -- Roger Glover glover_roger@xxxxxxxxx XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] [off-list] document(lang_*.xm, Mike Brown | Thread | Re: [xsl] [off-list] document(lang_, Daniel Veillard |
Re: [xsl] FOP not working on Debian, Zack Brown | Date | Re: [xsl] [off-list] document(lang_, Daniel Veillard |
Month |