Re: ksh cd two args

2016-08-31 Thread Alexander Hall
On Wed, Aug 31, 2016 at 01:53:30PM +0100, Theo Buehler wrote:
> On Wed, Aug 31, 2016 at 08:39:51AM -0400, Ted Unangst wrote:
> > About ten times a day I do something like this:
> > $ cd cd tedu
> > ksh: cd: bad substitution
> > 
> > What does that even mean? According to the source, but not the manual, there
> > is some two argument cd syntax which substitutes something. I have never 
> > once
> > tried to do this on purpose.
> > 
> > Thus, I think the error message should be changed to be more appropriate.
> > Those few power users who try to substitute paths can probably deal with the
> > error message better than I can.
> 
> But the error message "too many arguments" doesn't make sense for the
> two-argument cd. The two-argument cd is documented:
> 
>  cd [-LP] old new
>   The string new is substituted for old in the current 
> directory,
> and the shell attempts to change to the new directory.

I agree. Feel free to improve the error message, but please keep it accurate.

As for how I (albeit rarely) have used it:

$ pwd
/usr/src/usr.bin/ssh
$ cd src src/regress
/usr/src/regress/usr.bin/ssh
$ pwd
/usr/src/regress/usr.bin/ssh

/Alexander



Re: ksh cd two args

2016-08-31 Thread Theo Buehler
On Wed, Aug 31, 2016 at 08:39:51AM -0400, Ted Unangst wrote:
> About ten times a day I do something like this:
> $ cd cd tedu
> ksh: cd: bad substitution
> 
> What does that even mean? According to the source, but not the manual, there
> is some two argument cd syntax which substitutes something. I have never once
> tried to do this on purpose.
> 
> Thus, I think the error message should be changed to be more appropriate.
> Those few power users who try to substitute paths can probably deal with the
> error message better than I can.

But the error message "too many arguments" doesn't make sense for the
two-argument cd. The two-argument cd is documented:

 cd [-LP] old new
  The string new is substituted for old in the current 
directory,
  and the shell attempts to change to the new directory.



ksh cd two args

2016-08-31 Thread Ted Unangst
About ten times a day I do something like this:
$ cd cd tedu
ksh: cd: bad substitution

What does that even mean? According to the source, but not the manual, there
is some two argument cd syntax which substitutes something. I have never once
tried to do this on purpose.

Thus, I think the error message should be changed to be more appropriate.
Those few power users who try to substitute paths can probably deal with the
error message better than I can.

Index: c_ksh.c
===
RCS file: /cvs/src/bin/ksh/c_ksh.c,v
retrieving revision 1.50
diff -u -p -r1.50 c_ksh.c
--- c_ksh.c 21 Mar 2016 13:35:00 -  1.50
+++ c_ksh.c 31 Aug 2016 12:36:53 -
@@ -82,7 +82,7 @@ c_cd(char **wp)
 * we don't
 */
if ((cp = strstr(current_wd, wp[0])) == NULL) {
-   bi_errorf("bad substitution");
+   bi_errorf("too many arguments");
return 1;
}
ilen = cp - current_wd;