add standard variable PATHSEP, for better and easier OS/2 support

This commit is contained in:
tg 2017-03-19 22:31:29 +00:00
parent 0530264293
commit 9466b49fe8
5 changed files with 39 additions and 16 deletions

26
check.t
View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.763 2017/03/19 20:59:23 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.764 2017/03/19 22:31:24 tg Exp $
# -*- mode: sh -*-
#-
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
@ -30,7 +30,7 @@
# (2013/12/02 20:39:44) http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date
expected-stdout:
@(#)MIRBSD KSH R54 2017/03/17
@(#)MIRBSD KSH R54 2017/03/19
description:
Check version of shell.
stdin:
@ -39,7 +39,7 @@ name: KSH_VERSION
category: shell:legacy-no
---
expected-stdout:
@(#)LEGACY KSH R54 2017/03/17
@(#)LEGACY KSH R54 2017/03/19
description:
Check version of legacy shell.
stdin:
@ -102,6 +102,26 @@ stdin:
expected-stdout:
-c echo foo
---
name: selftest-pathsep-unix
description:
Check that $PATHSEP is set correctly.
category: !os:os2
stdin:
PATHSEP=.; export PATHSEP
"$__progname" -c 'print -r -- $PATHSEP'
expected-stdout:
:
---
name: selftest-pathsep-os2
description:
Check that $PATHSEP is set correctly.
category: os:os2
stdin:
PATHSEP=.; export PATHSEP
"$__progname" -c 'print -r -- $PATHSEP'
expected-stdout:
;
---
name: alias-1
description:
Check that recursion is detected/avoided in aliases.

View File

@ -1,5 +1,5 @@
# $Id$
# $MirOS: src/bin/mksh/dot.mkshrc,v 1.113 2017/03/19 21:08:25 tg Exp $
# $MirOS: src/bin/mksh/dot.mkshrc,v 1.114 2017/03/19 22:31:26 tg Exp $
#-
# Copyright (c) 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010,
# 2011, 2012, 2013, 2014, 2015, 2016, 2017
@ -588,9 +588,10 @@ function enable {
\: place customisations below this line
[[ $PATH = *\;?:\\* ]] || for p in ~/.etc/bin ~/bin; do
for p in ~/.etc/bin ~/bin; do
[[ -d $p/. ]] || \\builtin continue
[[ :$PATH: = *:$p:* ]] || PATH=$p:$PATH
[[ $PATHSEP$PATH$PATHSEP = *"$PATHSEP$p$PATHSEP"* ]] || \
PATH=$p$PATHSEP$PATH
done
\\builtin export SHELL=$MKSH MANWIDTH=80 LESSHISTFILE=-

3
main.c
View File

@ -34,7 +34,7 @@
#include <locale.h>
#endif
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.327 2017/03/19 22:23:45 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.328 2017/03/19 22:31:27 tg Exp $");
extern char **environ;
@ -364,6 +364,7 @@ main_init(int argc, const char *argv[], Source **sp, struct block **lp)
typeset("IFS= \t\n", 0, 0, 0, 0);
/* assign default shell variable values */
typeset("PATHSEP=" MKSH_PATHSEPS, 0, 0, 0, 0);
substitute(initsubs, 0);
/* Figure out the current working directory and set $PWD */

15
mksh.1
View File

@ -1,4 +1,4 @@
.\" $MirOS: src/bin/mksh/mksh.1,v 1.434 2017/03/19 22:04:49 tg Exp $
.\" $MirOS: src/bin/mksh/mksh.1,v 1.435 2017/03/19 22:31:27 tg Exp $
.\" $OpenBSD: ksh.1,v 1.160 2015/07/04 13:27:04 feinerer Exp $
.\"-
.\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
@ -2020,9 +2020,11 @@ searched when looking for commands and files sourced using the
.Dq Li \&.
command (see below).
An empty string resulting from a leading or trailing
colon, or two adjacent colons, is treated as a
(semi)colon, or two adjacent ones, is treated as a
.Dq Li \&.
(the current directory).
.It Ev PATHSEP
A colon (semicolon on OS/2), for the user's convenience.
.It Ev PGRP
The process ID of the shell's process group leader.
.It Ev PIPESTATUS
@ -6682,11 +6684,10 @@ Any privilege pop-ups you might be encountering are thus not
.Nm mksh
issues but questions by some other program utilising it.
.Ss "I'm an OS/2 user, what do I need to know?"
Unlike the native command prompt, the current working directory is
not in the search path at all, for security reasons common on Unix
systems (the shell is designed for Unix-like systems); if you really
need this, run the command
.Li PATH=".;$PATH"
Unlike the native command prompt, the current working directory is,
for security reasons common on Unix systems which the shell is designed for,
not in the search path at all; if you really need this, run the command
.Li PATH=.$PATHSEP$PATH
or add that to a suitable initialisation file.
.Pp
You will have gotten this shell through komh's port on Shellworld

4
sh.h
View File

@ -175,9 +175,9 @@
#endif
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.795 2017/03/17 22:45:53 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.796 2017/03/19 22:31:29 tg Exp $");
#endif
#define MKSH_VERSION "R54 2017/03/17"
#define MKSH_VERSION "R54 2017/03/19"
/* arithmetic types: C implementation */
#if !HAVE_CAN_INTTYPES