APLawrence - Information and Resources for Unix and Linux Systems, Bloggers and the self-employed
RSS Feeds Get APLawrence.com by RSS











(OLDER) <- More Stuff -> (NEWER) (NEWEST)
Home > News Posts > sed script echo extra argument ––>Re: misbehavingsed
Printer Friendly Version




News Group Posts

sed script echo extra argument




From: Bela Lubkin <belal@sco.com>
Subject: Re: misbehaving sed
Date: Wed, 24 Oct 2001 10:13:26 GMT
References: <20011024001157.A17650@jpradley.jpr.com> 

Jean-Pierre Radley wrote:

> Consider this script:
> 
>    #!/bin/sh
>    AAA="/a/b/c"
>    BBB=`echo $AAA | /bin/sed -e 's/.*\///'`
>    echo ..$BBB..
> 
> As expected, I run this and get
>    ..c..
> 
> This is a simplified version of some commands in the .../bin/visionfs
> script (which I personally would have written using 'basename' and no
> pipe).
> 
> On a customer's machine, I just installed
>    rs506a
>    sse071
>    sse072c
>    sse073
>    CSSA-2001-SCO.1
>    CSSA-2001-SCO.10
>    CSSA-2001-SCO.12
>    CSSA-2001-SCO.17
>    CSSA-2001-SCO.20
> 
> My script, on that machine errs and writes out:
>    ..c ..
> 
> [The visionfs script barfs:
>    Unable to open message file:
>    /usr/vision/visionfs/_inst/en_US /visionfs
> failing because of that trailing space introduced by the sed command.]
> 
> NB: sed isn't changed by any of the mentioned patches, and both the
> customer's machine and mine have the same libc.so.1 file out of rs506a.














The problem is not in sed.  This script will produce the same failure:

  #!/bin/sh
  BBB=`echo c`
  echo ..$BBB..

The problem is in fact in /bin/sh, which you installed from
CSSA-2001-SCO.24 (which you didn't mention).

The CSSA-2001-SCO.24 version of /bin/sh, /sbin/sh and
/usr/lib/scosh/utilbin/oash has a bug in its built-in "echo" command; it
sees one more argument than you specified, and thus outputs an extra
space (to separate the last real argument from the false one).  The
content of this false extra argument are always empty, so you just get
an extra space.

CSSA-2001-SCO.24 will be updated or replaced (I don't know what the
current policy is) to fix this.

>Bela<
 

If this page was useful to you, please click to help others find it:  

Your +1's can help friends, contacts, and others on the web find the best stuff when they search.

1 comment



Click here to add your comments





Sat Aug 21 20:42:58 2010:   Sathish

gravatar
Hi
I have a script like below
#! /bin/ksh
echo $1
echo $2


I saved the program as test.ksh, when i run this from the command line like
test.ksh abc def

Its not echoing the parameters passed where as if i run like
ksh test.ksh abc def
its working fine-i just wnat to know hwy the option 1 is not running
Your help is appraeciated


Don't miss responses! Subscribe to Comments by RSS or by Email

Click here to add your comments


If you want a picture to show with your comment, go get a Gravatar



Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.

Publishing your articles here

Jump to Comments



Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.

Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.

We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.

g_face.jpg

This post tagged:

       - Bela
       - SCO_OSR5




Unix/Linux Consultants

Skills Tests

Guest Post Here