[Bug 1381965] Re: mksh R50d: parser fixes break common “set -u” workaround, take two

2014-10-19 Thread Thorsten Glaser
Preliminary fix (as posted) committed and uploaded to Debian.
Better fix committed, needs more testing.

** Changed in: mksh
   Status: Confirmed = In Progress

** Changed in: mksh
 Assignee: (unassigned) = Thorsten Glaser (mirabilos)

-- 
You received this bug notification because you are a member of mksh
Mailing List, which is subscribed to mksh.
Matching subscriptions: mkshlist-to-mksh-bugmail
https://bugs.launchpad.net/bugs/1381965

Title:
  mksh R50d: parser fixes break common “set -u” workaround, take two

Status in The MirBSD Korn Shell:
  In Progress

Bug description:
  tglase@tglase:~ $ cat x
  list_parts() {
  local regex=${2:-}
  local args=x
  if [ -n $regex ]; then
  args=${args} -regex '$regex'
  fi  
  printf '%s\n' $args
  }
  list_parts foo
  tglase@tglase:~ $ bash x
  x
  tglase@tglase:~ $ env -i PATH=$PATH mksh x
  typeset -i -U BASHPID
  typeset -i COLUMNS
  typeset EPOCHREALTIME
  typeset -x HOME
  typeset IFS
  typeset -i -U KSHEGID
  typeset -i -U KSHGID
  typeset -i -U KSHUID
  typeset -r KSH_VERSION
  typeset -i LINES
  typeset -i OPTIND
  typeset -x PATH
  typeset -i -U PGRP
  set -A PIPESTATUS
  typeset -i -r -U PIPESTATUS[0]
  typeset -i -U PPID
  typeset PS1
  typeset PS2
  typeset PS3
  typeset PS4
  typeset PWD
  typeset -i -U RANDOM
  typeset -i SECONDS
  typeset -x SHELL
  typeset -i TMOUT
  typeset -i -U USER_ID
  x

  Breaks: php5 maintainer scripts

To manage notifications about this bug go to:
https://bugs.launchpad.net/mksh/+bug/1381965/+subscriptions


[Bug 1381993] Re: more fun with $*

2014-10-19 Thread Thorsten Glaser
Preliminary fix committed, plus some test coverage. This is a real
problem, raising priority.

Fix needs to be extended; CVS HEAD needs to be tested better.

** Changed in: mksh
   Importance: Low = High

** Changed in: mksh
   Status: New = In Progress

** Changed in: mksh
 Assignee: (unassigned) = Thorsten Glaser (mirabilos)

-- 
You received this bug notification because you are a member of mksh
Mailing List, which is subscribed to mksh.
Matching subscriptions: mkshlist-to-mksh-bugmail
https://bugs.launchpad.net/bugs/1381993

Title:
  more fun with $*

Status in The MirBSD Korn Shell:
  In Progress

Bug description:
  From: Stephane Chazelas stephane.chaze...@gmail.com

  BTW, it looks like there's a bug in mksh:

  tglase@tglase:~ $ bash -c 'IFS=; x=abc; printf %s\n ${x#$*}' x a b | sed 
-n l
  abc$
  tglase@tglase:~ $ ./dash -c 'IFS=; x=abc; printf %s\n ${x#$*}' x a b | 
sed -n l
  c$
  tglase@tglase:~ $ ksh93 -c 'IFS=; x=abc; printf %s\n ${x#$*}' x a b | sed 
-n l
  c$
  tglase@tglase:~ $ lksh -c 'IFS=; x=abc; printf %s\n ${x#$*}' x a b | sed 
-n l
  \a\300a$
  abc$
  tglase@tglase:~ $ mksh -c 'IFS=; x=abc; printf %s\n ${x#$*}' x a b | sed 
-n l
  \a\300a$
  abc$
  tglase@tglase:~ $ pdksh-5.2.14 -c 'IFS=; x=abc; printf %s\n ${x#$*}' x a 
b | sed -n l  
  abc$
  tglase@tglase:~ $ mksh -o sh -c 'IFS=; x=abc; printf %s\n ${x#$*}' x a b 
| sed -n l
  a$
  abc$

  The dash versions I have access to give the expected output
  (same as your ksh93).

  bash and pdksh join the arguments with spaces. And there's
  nothing in POSIX that allows them to do that.

  But:

  ksh93 has some other interesting bugs:

  tglase@tglase:~ $ bash -c 'IFS=*; a=abcd; printf %s\n $* ${a##$*}' 
sh '' c
  *c
  abcd
  tglase@tglase:~ $ ./dash -c 'IFS=*; a=abcd; printf %s\n $* 
${a##$*}' sh '' c
  *c
  abcd
  tglase@tglase:~ $ ksh93 -c 'IFS=*; a=abcd; printf %s\n $* ${a##$*}' 
sh '' c
  *c
  d
  tglase@tglase:~ $ lksh -c 'IFS=*; a=abcd; printf %s\n $* ${a##$*}' 
sh '' c
  *c
  abcd
  tglase@tglase:~ $ mksh -c 'IFS=*; a=abcd; printf %s\n $* ${a##$*}' 
sh '' c
  *c
  abcd
  tglase@tglase:~ $ pdksh-5.2.14 -c 'IFS=*; a=abcd; printf %s\n $* 
${a##$*}' sh '' c   
  *c
  abcd

  tl;dr: Fix the first and keep the second as-is.

  And they don't say how those arrays are to be cast to scalars
  when not in list context since they don't specify arrays in the
  first place.
  
  The non-list contexts include
  
  a=$*
  ${a#$*}
  
  case x in
$a) ...;;
$a) ...
  esac
  ${a#$*} # beware quotes also serve to cancel globs there
  
  $(( $* ))
  ...

  Interesting use for the asn subst.

To manage notifications about this bug go to:
https://bugs.launchpad.net/mksh/+bug/1381993/+subscriptions