diff -Naur Expect-1.15/Expect.pm Expect-new/Expect.pm --- Expect-1.15/Expect.pm Tue Mar 19 06:59:29 2002 +++ Expect-new/Expect.pm Fri Aug 22 08:07:35 2003 @@ -86,7 +86,25 @@ return $self; } +# Mac OS X has a bug in pty. This is a workaround, but it requires that +# the spawned process be exec'ed through a shell, rather than directly. +# If this causes problem, call spawn_orig(@cmd) instead of spawn(@cmd). sub spawn { + my $self = shift; + my $cmd; + if ( @_ > 1 ) { + # Force the real error if command not found. + return $self->spawn_orig(@_) if system("which $_[0] >& /dev/null") != 0; + $cmd = join( ' ', map { "\Q$_\E" } @_ ) . " && sleep 1"; + } else { + return $self->spawn_orig(@_) + if $_[0] =~ /^(\S*)/ and system("which $1 >& /dev/null") != 0; + $cmd = $_[0] . " && sleep 1"; + } + $self->spawn_orig($cmd); +} + +sub spawn_orig { my ($class) = shift; my $self;