HomeFreeBSD

sh(1): Do not interpret chdir to "" as equivalent to chdir with no argument

Description

sh(1): Do not interpret chdir to "" as equivalent to chdir with no argument

A script that does the following:

cd "${dir}" || exit 1

would incorrectly remain in the current directory when ${dir} is
an empty string under the current implementation. This behavior,
while historical, is potentially dangerous, as it is likely not
what the script author intended.

Change the command to treat an empty string as an error and emit a
diagnostic message to standard error, as required by
IEEE Std 1003.1-2024.

PR: standards/287440
Test Plan: kyua test bin/sh
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D50974

Details

Provenance
delphijAuthored on Jul 2 2025, 5:09 AM
Differential Revision
D50974: sh(1): Do not interpret chdir to "" as equivalent to chdir with no argument
Parents
rG65bc8e9192dd: pf.4: Add pf_enable to SYNOPSIS
Branches
Unknown
Tags
Unknown