Bug 297181 - Mk/Uses/npm.mk has unquoted TMPDIR comparison
Summary: Mk/Uses/npm.mk has unquoted TMPDIR comparison
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Hiroki Tagato
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-07-31 01:05 UTC by Shin-ichi Nagamura
Modified: 2026-07-31 22:12 UTC (History)
1 user (show)

See Also:


Attachments
Quote TMPDIR and WRKDIR in npm.mk shell comparisons (780 bytes, patch)
2026-07-31 01:05 UTC, Shin-ichi Nagamura
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Shin-ichi Nagamura 2026-07-31 01:05:56 UTC
Created attachment 273334 [details]
Quote TMPDIR and WRKDIR in npm.mk shell comparisons

Mk/Uses/npm.mk contains two shell tests with an unquoted TMPDIR variable.

When TMPDIR is unset, the generated shell command becomes:

    if [ != ${WRKDIR} ]; then

and /bin/sh reports:

    [: !=: unexpected operator

This happens during "Archiving prefetched node modules" in npm:fetch.

Quoting both variables fixes the issue:

    if [ "${TMPDIR}" != "${WRKDIR}" ]; then
Comment 1 Hiroki Tagato freebsd_committer freebsd_triage 2026-07-31 09:11:50 UTC
Good catch!
Comment 2 commit-hook freebsd_committer freebsd_triage 2026-07-31 09:18:56 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=cbeb1be34ba3107114345e52c6b57adc2ec34060

commit cbeb1be34ba3107114345e52c6b57adc2ec34060
Author:     Shin-ichi Nagamura <core@zsc.jp>
AuthorDate: 2026-07-31 09:15:29 +0000
Commit:     Hiroki Tagato <tagattie@FreeBSD.org>
CommitDate: 2026-07-31 09:15:29 +0000

    Mk/Uses/npm.mk: Quote TMPDIR and WRKDIR in shell comparisons

    When TMPDIR is unset, the generated shell command becomes:
        if [ != ${WRKDIR} ]; then
    and /bin/sh reports:
        [: !=: unexpected operator

    Quoting both variables fixes the issue.

    PR:             297181
    Reported by:    Shin-ichi Nagamura <core@zsc.jp>

 Mk/Uses/npm.mk | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Comment 3 Hiroki Tagato freebsd_committer freebsd_triage 2026-07-31 09:20:29 UTC
Committed, thanks!
Comment 4 Shin-ichi Nagamura 2026-07-31 22:12:18 UTC
Thank you so much for the super fast commit!

迅速な対応ありがとうございました。