Skip to content

Commit fe0c4c1

Browse files
authored
Merge branch 'dev' into fix-fd-closing
2 parents 24a0186 + 11981f5 commit fe0c4c1

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

src/cmd/ksh93/include/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <ast_release.h>
1919
#include "git.h"
2020

21-
#define SH_RELEASE_DATE "2025-06-19" /* must be in this format for $((.sh.version)) */
21+
#define SH_RELEASE_DATE "2025-06-22" /* must be in this format for $((.sh.version)) */
2222
/*
2323
* This comment keeps SH_RELEASE_DATE a few lines away from SH_RELEASE_SVER to avoid
2424
* merge conflicts when cherry-picking dev branch commits onto a release branch.

src/cmd/ksh93/sh/path.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static void funload(int,const char*);
4646
static void noreturn exscript(char*, char*[]);
4747
static int checkdotpaths(Pathcomp_t*,Pathcomp_t*,Pathcomp_t*,int);
4848
static void checkdup(Pathcomp_t*);
49-
static Pathcomp_t *defpathinit(void);
49+
static Pathcomp_t *defpath(void);
5050

5151
static const char *std_path(void)
5252
{
@@ -406,9 +406,12 @@ Pathcomp_t *path_nextcomp(Pathcomp_t *pp, const char *name, Pathcomp_t *last)
406406
return NULL;
407407
}
408408

409-
static Pathcomp_t* defpathinit(void)
409+
static Pathcomp_t *defpath(void)
410410
{
411-
return path_addpath(NULL,std_path(),PATH_PATH);
411+
static Pathcomp_t *dp;
412+
if (!dp)
413+
dp = path_addpath(NULL, std_path(), PATH_PATH);
414+
return dp;
412415
}
413416

414417
static void pathinit(void)
@@ -419,7 +422,7 @@ static void pathinit(void)
419422
sh.pathlist = pp = path_addpath((Pathcomp_t*)sh.pathlist,val,PATH_PATH);
420423
else
421424
{
422-
pp = defpathinit();
425+
pp = defpath();
423426
sh.pathlist = path_dup(pp);
424427
}
425428
if(val=sh_scoped((FPATHNOD))->nvalue)
@@ -441,7 +444,7 @@ Pathcomp_t *path_get(const char *name)
441444
pp = (Pathcomp_t*)sh.pathlist;
442445
}
443446
if(!pp && (!(sh_scoped(PATHNOD)->nvalue)) || sh_isstate(SH_DEFPATH))
444-
pp = defpathinit();
447+
pp = defpath();
445448
return pp;
446449
}
447450

@@ -1619,7 +1622,7 @@ Pathcomp_t *path_addpath(Pathcomp_t *first, const char *path,int type)
16191622
if(old)
16201623
{
16211624
if(!first && !path)
1622-
first = path_dup(defpathinit());
1625+
first = path_dup(defpath());
16231626
if(cp=(sh_scoped(FPATHNOD))->nvalue)
16241627
first = path_addpath((Pathcomp_t*)first,cp,PATH_FPATH);
16251628
path_delete(old);

src/cmd/ksh93/tests/leaks.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ DO
356356
hash "${random_utils[@]}"
357357
DONE
358358

359-
TEST title='unset PATH in main shell' known=y url=https://github.com/ksh93/ksh/issues/405
359+
TEST title='unset PATH in main shell'
360360
DO
361361
unset PATH
362362
PATH=$save_PATH
@@ -445,5 +445,11 @@ DO
445445
(((foo = amet) && foo == amet && foo != fermentum))
446446
DONE
447447

448+
# ======
449+
TEST title='running external command by default path'
450+
DO
451+
command -px true
452+
DONE
453+
448454
# ======
449455
exit $((Errors<125?Errors:125))

0 commit comments

Comments
 (0)