Index | Thread | Search

From:
Steffen Nurpmeso <steffen@sdaoden.eu>
Subject:
Re: bin/ksh: add bash-like expand-tilde option
To:
tech@openbsd.org
Date:
Sat, 25 Apr 2026 21:56:02 +0200

Download raw body.

Thread
Hello Kirill.

Kirill A. Korinsky wrote in
 <87qzo375gk.wl-kirill@korins.ky>:
 |On Fri, 24 Apr 2026 22:51:17 +0200,
 |Steffen Nurpmeso <steffen@sdaoden.eu> wrote:
 |> 
 |> Kirill A. Korinsky wrote in
 |>  <87tst06uss.wl-kirill@korins.ky>:
 |>|tech@,
 |>|
 |>|default ksh completion already matches bash with expand-tilde enabled:
 |>|typing ~/sr and pressing TAB expands and completes the word to
 |>|/home/user/src.
 |>|
 |>|Here a new option expand-tilde which using the bash name, but keep
 |>|current ksh behaviour by enabling it by default.
 |>|
 |>|Disabling the option preserves the original ~ prefix, so the same input
 |>|completes to ~/src.
 |> 
 |> (Sorry for the noise -- i have not tried the patch --
 |> "expand-tilde" is a setting of the readline(3) library, and it
 |> affects quite a lot of programs on my box.  Indeed, i keep the
 |> default, "off".
 |> But still i do not get your explanation from last time.
 |> If you hit TAB -- with bash -- the only difference is whether
 |> $HOME (of X) is expanded, or not.  You still get the complete file
 |> list right away:
 |> 
 |>   $ bind 'set expand-tilde on'
 |>   $ echo ~/.a<TAB>
 |>   .a   .ax
 |>   $ echo /home/steffen/.a
 |> 
 |>   $ bind 'set expand-tilde off'
 |>   $ echo ~/.a
 |>   .a   .ax
 |>   $ echo ~/.a
 |> 
 |> So it seems to me that flow is the actual difference,
 |> "expand-tilde" has nothing to do with that.
 |> 
 |
 |Yes, I'd like to have that behaviour when original ~/.a is preserved in the
 |shell input and in the history file for C-r.

History is a very good reason, indeed.

(In fact i struggle with the same also for expansion of "+" <>
"mail folder", and even manually edited history in the past to
avoid effective duplicates, really.)

 |With my patch it adds it to set +o and set -o level, so it works like this:
 |
 |~ $ set +o expand-tilde
 |~ $ echo ~/sr
 |
 |now I press TAB and last line is
 |
 |~ $ echo ~/src
 |
 |~ $ set -o expand-tilde
 |~ $ echo ~/sr
 |
 |turns the last line by TAB into
 |
 |~ $ echo /home/catap/src/                                          \
 |
 |Maybe expand-tilde is odd name which confuses, but somehow it is a common
 |term for that, I think.

Yes, cool, yes.  (That "single expansion" is different to what
you said in January i think it was.)  Great!  I like that.

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)