DragonFly BSD
DragonFly bugs List (threaded) for 2004-02
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

backquote expansion bug in /bin/sh ( fix included )


From: Andrew Atrens <atrens@xxxxxxxxxxxxxxxxxx>
Date: Wed, 04 Feb 2004 15:42:01 -0500

Hi Folks,

Not sure how long this has been broken but ...

Using the following test script -

-- root@atrens: /usr/dfly/devel/src/bin/sh (14:43) --
# cat bug.sh


test() {
   /bin/echo "hello"
   /bin/echo ""
   /bin/echo ""
   /bin/echo ""
   /bin/echo ""
   /bin/echo ""
   /bin/echo ""
   /bin/echo ""
}

echo ">>`test`<<"


I see the following behaviours -

-- root@atrens: /usr/dfly/devel/src/bin/sh (14:43) --
# zsh bug.sh
>>hello<<

-- root@atrens: /usr/dfly/devel/src/bin/sh (14:43) --
# bash bug.sh
>>hello<<

-- root@atrens: /usr/dfly/devel/src/bin/sh (14:44) --
# ksh bug.sh
>>hello<<

-- root@atrens: /usr/dfly/devel/src/bin/sh (14:44) --
# sh bug.sh
>>hello






<<

When I put ksh, bash, or zsh into 'sh' mode by creating (and using) a 'sh'
link to them their behaviour does not change.

Here's a patch to sh, which fixes this -


"/usr/bin/cvs" -z3 -Q diff -N -b -B -kk  -r 1.3 -r 1.3.2.1 "expand.c"
Index: expand.c
===================================================================
RCS file: /usr/dfly/repo/src/bin/sh/expand.c,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -b -B -r1.3 -r1.3.2.1
472c472
<       for (p--; lastc == '\n'; lastc = *--p)
---
>       for ( ; *(dest-1) == '\n' ; )





I've installed my patched /bin/sh and successfully completed a 'make
buildworld' with it. It would be cool if someone could review/commit this.

Cheers,

Andrew.







[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]