Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unbuffer (and other scripts) from the expect package relies on PATH #5230

Open
1 task done
tunaflsh opened this issue Feb 23, 2025 · 1 comment
Open
1 task done
Labels

Comments

@tunaflsh
Copy link

Description / Steps to reproduce the issue

  1. pacman -Sy expect
  2. cat /usr/bin/unbuffer
#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
exec tclsh "$0" ${1+"$@"}

package require Expect


# -*- tcl -*-
# Description: unbuffer stdout of a program
# Author: Don Libes, NIST

if {[string compare [lindex $argv 0] "-p"] == 0} {
    # pipeline
    set stty_init "-echo"
    eval [list spawn -noecho] [lrange $argv 1 end]
    close_on_eof -i $user_spawn_id 0
    interact {
        eof {
            # flush remaining output from child
            expect -timeout 1 -re .+
            return
        }
    }
} else {
    set stty_init "-opost"
    set timeout -1
    eval [list spawn -noecho] $argv
    expect
    exit [lindex [wait] 3]
}

As you can see tclsh is searched from PATH so running this script in other environments would break:

can't find package Expect

This is in all shell scripts installed by the expect package.

Expected behavior

- exec tclsh "$0" ${1+"$@"}
+ exec /usr/bin/tclsh "$0" ${1+"$@"}

Actual behavior

can't find package Expect

Verification

Windows Version

MSYS_NT-10.0-26100

Are you willing to submit a PR?

Maybe. I haven't gotten familiar with packaging yet.

@tunaflsh tunaflsh added the bug label Feb 23, 2025
@lazka
Copy link
Member

lazka commented Mar 3, 2025

Your proposed fix looks good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants