[PATCH v3 1/3] selftests: kselftest: avoid cd - in runner

Pedro Falcato pfalcato at suse.de
Mon Sep 28 10:27:39 PDT 2026


On Sat, Sep 26, 2026 at 10:08:17AM +0900, Hajime Tazaki wrote:
> The kselftest runner currently uses `cd -` to restore its working
> directory after running a test.
> 
> This is not supported by the minimal BusyBox hush shell used by some
> NOMMU targets. Store the original directory explicitly and restore it
> with a quoted path instead.
> 
> This also avoids printing the directory change performed by `cd -` and
> handles paths containing whitespace correctly.
> 
> Cc: Shuah Khan <shuah at kernel.org>
> Cc: Kees Cook <kees at kernel.org>
> Cc: Andy Lutomirski <luto at amacapital.net>
> Cc: Will Drewry <wad at chromium.org>
> Cc: Mark Brown <broonie at kernel.org>
> Cc: Brendan Jackman <brendan.jackman at linux.dev>
> Cc: Hangbin Liu <liuhangbin at gmail.com>
> Cc: "Ricardo B. Marliere" <rbm at suse.com>
> Cc: linux-kselftest at vger.kernel.org
> Cc: linux-um at lists.infradead.org
> Cc: linux-mm at kvack.org
> Signed-off-by: Hajime Tazaki <thehajime at gmail.com>

NACK.

https://pubs.opengroup.org/onlinepubs/009695099/utilities/cd.html

-
When a hyphen is used as the operand, this shall be equivalent to the command:
cd "$OLDPWD" && pwd

which changes to the previous working directory and then writes its name.


If you're running selftests on !POSIX compliant shells, that's a
you-issue. Fix the shell, or use something decent.


-- 
Pedro



More information about the linux-um mailing list