Skip to content

Inconsistent return code #150

@kaisermann

Description

@kaisermann

I'm trying to check if my remote machine has a specific command by using which and checking its return code.

const hasWPCLI = transport.exec('which wp', { failsafe: true });
if(hasWPCLI.code !== 0) {
  ...
}

However, I'm getting some strange results as sometimes it is returned '1' and sometimes '0'.

Returning 0:

✈ Running setup:staging
✈ Connecting to 'x.x.x.x'
✈ Executing remote task on x.x.x.x
x.x.x.x $ which wp
x.x.x.x > which: no wp in (/usr/local/bin:/bin:/usr/bin:/usr/local/bin)
x.x.x.x ● ok

Returning 1:

✈ Running setup:staging
✈ Connecting to 'x.x.x.x'
✈ Executing remote task on x.x.x.x
x.x.x.x $ which wp
x.x.x.x > which: no wp in (/usr/local/bin:/bin:/usr/bin:/usr/local/bin)
x.x.x.x ● failed safely (1)

Both calls were made seconds apart from each other.

Any thoughts on what's happening? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions