Review Request 119285: Fix Empty String Test in kdevelop! Shell Script
Kevin Funk
kfunk at kde.org
Tue Jul 15 09:31:27 UTC 2014
> On July 15, 2014, 8:17 a.m., Kevin Funk wrote:
> > kdevelop! is a sh script -- '[[' is a bash thing only.
> >
> > I'd suggest the following patch, which also doesn't fail if $@ contains a hyphen as the first char.
> >
> > --- a/app/kdevelop!
> > +++ b/app/kdevelop!
> > @@ -23,7 +23,7 @@ export APPLICATION=KDevelop
> >
> > if ! [ "$KDEV_ATTACHED_PID" ]; then
> > ARGS=""
> > - if [[ -z "$@" ]]; then
> > + if [ $# -eq 0 ]; then
> > ARGS="-pss"
> > else
> > ARGS="$@"
> >
> > Feel free to commit that one if that fixes it for you, too.
>
> Kevin Funk wrote:
> Okay. Reviewboard messed up my patch. But I think you get the idea...
>
> Milian Wolff wrote:
> You could just use
>
> if [ -z "$@" ]; then
> ...
>
> no? That works just fine for me...
>
> $ if [ -z "$a" ]; then echo 1; else echo 2; fi
> 1
> $ a=1;
> $ if [ -z "$a" ]; then echo 1; else echo 2; fi
> 2
That's not safe (good old 'sh' problem again): If "$@" contains a leading dash it is interpreted as operator.
% kdevelop! -s "{e70bb2c0-fad8-4b21-96f7-71ba9712390c}"
/home/krf/devel/install/master/bin/kdevelop!: 26: [: -s: unexpected operator
- Kevin
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/119285/#review62379
-----------------------------------------------------------
On July 15, 2014, 3:17 a.m., David Narváez wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/119285/
> -----------------------------------------------------------
>
> (Updated July 15, 2014, 3:17 a.m.)
>
>
> Review request for KDevelop.
>
>
> Bugs: 337454
> http://bugs.kde.org/show_bug.cgi?id=337454
>
>
> Repository: kdevelop
>
>
> Description
> -------
>
> This empty string test was failing and causing the linked bug.
>
>
> Diffs
> -----
>
> app/kdevelop! 35dda2d
>
> Diff: https://git.reviewboard.kde.org/r/119285/diff/
>
>
> Testing
> -------
>
> See the steps to reproduce the linked bug.
>
>
> Thanks,
>
> David Narváez
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20140715/14e74430/attachment.html>
More information about the KDevelop-devel
mailing list