Print error if PATH is empty.

This fixes #881.

Before:
```bash
$ PATH= /usr/bin/yay -Qu
$ echo $?
1
```

After:
```bash
$ PATH= ./yay -Qu
exec: "pacman-conf": executable file not found in $PATH
$ echo $?
1
```
This commit is contained in:
xhqr 2020-12-23 18:45:24 +01:00 committed by J Guerreiro
parent 607d28778e
commit 24edabe5df
3 changed files with 7 additions and 6 deletions

View file

@ -30,7 +30,11 @@ func initAlpm(cmdArgs *settings.Arguments, pacmanConfigPath string) (*pacmanconf
pacmanConf, stderr, err := pacmanconf.PacmanConf("--config", pacmanConfigPath, "--root", root)
if err != nil {
return nil, false, fmt.Errorf("%s", stderr)
cmdErr := err
if stderr != "" {
cmdErr = fmt.Errorf("%s\n%s", err, stderr)
}
return nil, false, cmdErr
}
if dbPath, _, exists := cmdArgs.GetArg("dbpath", "b"); exists {

View file

@ -22,11 +22,7 @@ type OSRunner struct {
func (r *OSRunner) Show(cmd *exec.Cmd) error {
cmd.Stdin, cmd.Stdout, cmd.Stderr = os.Stdin, os.Stdout, os.Stderr
err := cmd.Run()
if err != nil {
return fmt.Errorf("")
}
return nil
return cmd.Run()
}
func (r *OSRunner) Capture(cmd *exec.Cmd, timeout int64) (stdout, stderr string, err error) {

View file

@ -202,6 +202,7 @@ func printUpdateList(cmdArgs *settings.Arguments, dbExecutor db.Executor, enable
os.Stdout = nil
localNames, remoteNames, err := query.GetPackageNamesBySource(dbExecutor)
if err != nil {
os.Stdout = old
return err
}