[Bug 1689648] Re: removing open bracket ([) via ${var#[} fails does not work on i386.

Scott Moser smoser at ubuntu.com
Tue May 9 20:33:54 UTC 2017


it generally seems to work for just about everything other than '['
# /bin/sh -c 'for i in "$@"; do var="${i}abc";
    [ "${var#$i}" = "$var" ] && echo "$i: broken" || echo "$i: ok"; done' \
    a b c '[' ']' d e f 1 2 3 '#' - _ = +
b: ok
c: ok
[: broken
]: ok
d: ok
e: ok
f: ok
1: ok
2: ok
3: ok
#: ok
-: ok
_: ok
=: ok
+: ok


** Description changed:

  dash in 14.04 has an odd bug in /bin/sh.
+    $ var="[abc"
+    $ echo "${var#[}"
+    [abc
  
+    That *should* output just 'abc' (and does everywhere other than
+ 14.04).
+ 
+ It is fairly easily workaroundable by quoting the '[':
+    $ var="[abc"
+    echo ${var#"["}
+ 
+ 
+ To demonstrate:
  $ lxc launch ubuntu-daily:trusty shbug
  $ lxc exec shbug /bin/bash
  
  % /bin/sh -c 'v=$0; echo ${v#[}' "[abc"
  [abc
  
  % dpkg -S /bin/sh
  diversion by dash from: /bin/sh
  diversion by dash to: /bin/sh.distrib
  dash: /bin/sh
  
  % dpkg-query --show dash
  dash  0.5.7-4ubuntu1
  % exit
- 
  
  ## show that on host, this works as expected.
  $ /bin/sh -c 'v=$0; echo ${v#[}' "[abc"
  abc
  $ dpkg-query --show dash
  dash  0.5.8-2.3ubuntu1
  
  ProblemType: Bug
  DistroRelease: Ubuntu 14.04
  Package: dash 0.5.7-4ubuntu1
  ProcVersionSignature: Ubuntu 4.10.0-20.22-generic 4.10.8
  Uname: Linux 4.10.0-20-generic i686
  ApportVersion: 2.14.1-0ubuntu3.23
  Architecture: i386
  Date: Tue May  9 20:13:57 2017
  ProcEnviron:
-  TERM=xterm-256color
-  PATH=(custom, no user)
-  LANG=C.UTF-8
+  TERM=xterm-256color
+  PATH=(custom, no user)
+  LANG=C.UTF-8
  SourcePackage: dash
  UpgradeStatus: No upgrade log present (probably fresh install)

** Summary changed:

- removing open bracket ([) via ${var#[} fails does not work on i386.
+ removing open bracket ([) via ${var#[} does not work.

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to dash in Ubuntu.
https://bugs.launchpad.net/bugs/1689648

Title:
  removing open bracket ([) via ${var#[} does not work.

Status in dash package in Ubuntu:
  Fix Released
Status in dash source package in Trusty:
  Confirmed

Bug description:
  dash in 14.04 has an odd bug in /bin/sh.
     $ var="[abc"
     $ echo "${var#[}"
     [abc

     That *should* output just 'abc' (and does everywhere other than
  14.04).

  It is fairly easily workaroundable by quoting the '[':
     $ var="[abc"
     echo ${var#"["}

  
  To demonstrate:
  $ lxc launch ubuntu-daily:trusty shbug
  $ lxc exec shbug /bin/bash

  % /bin/sh -c 'v=$0; echo ${v#[}' "[abc"
  [abc

  % dpkg -S /bin/sh
  diversion by dash from: /bin/sh
  diversion by dash to: /bin/sh.distrib
  dash: /bin/sh

  % dpkg-query --show dash
  dash  0.5.7-4ubuntu1
  % exit

  ## show that on host, this works as expected.
  $ /bin/sh -c 'v=$0; echo ${v#[}' "[abc"
  abc
  $ dpkg-query --show dash
  dash  0.5.8-2.3ubuntu1

  ProblemType: Bug
  DistroRelease: Ubuntu 14.04
  Package: dash 0.5.7-4ubuntu1
  ProcVersionSignature: Ubuntu 4.10.0-20.22-generic 4.10.8
  Uname: Linux 4.10.0-20-generic i686
  ApportVersion: 2.14.1-0ubuntu3.23
  Architecture: i386
  Date: Tue May  9 20:13:57 2017
  ProcEnviron:
   TERM=xterm-256color
   PATH=(custom, no user)
   LANG=C.UTF-8
  SourcePackage: dash
  UpgradeStatus: No upgrade log present (probably fresh install)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/dash/+bug/1689648/+subscriptions



More information about the foundations-bugs mailing list