Eric Blake <ebb9@byu.net> wrote, on 15 Jul 2009:
>
> > It is up to the application to deal with the double-slash issue in
> > relation to ~ in the same way it would deal with it for "$HOME".
>
> When using $HOME, the application can do just that - via "$HOME" in
> contrast to "${HOME%/}" given the context of whether they are following
> the expansion with /. But when using tilde expansion, the expansion is
> already performed before the user has a chance. By arguing that the
> application must deal with it, you are claiming that a conformant
> application cannot safely use tilde expansion as a substitute for $HOME.
I hadn't considered the use of "${HOME%/}". Historically, the
way to handle the double-slash issue when joining a directory
and a filename was either:
case $dir in
*/) pathname=$dir$filename ;;
*) pathname=$dir/$filename ;;
esac
or:
pathname=$dir//$filename
These techniques predate the standardisation of ${var%pattern} by
POSIX.2.
Both techniques can be used with ~ just the same as with "$HOME",
but you have a point that the more modern "${dir%/}" technique
can be used with "$HOME" but not with ~.
--
Geoff Clare <g.clare@opengroup.org>
The Open Group, Thames Tower, Station Road, Reading, RG1 1LX, England
|