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

/bin/sh: 1: set: Illegal option -o pipefail #20

Closed
hata6502 opened this issue May 7, 2021 · 3 comments
Closed

/bin/sh: 1: set: Illegal option -o pipefail #20

hata6502 opened this issue May 7, 2021 · 3 comments

Comments

@hata6502
Copy link

hata6502 commented May 7, 2021

Expected Behavior

The example script works correctly.

#!/usr/bin/env zx

// Copyright 2021 Google LLC
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
//     https://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

await $`ls -1 | wc -l`

let branch = await $`git branch --show-current`
await $`printf ${branch} | wc`

await $`test -f package.json`

Actual Behavior

The example script doen't work.

$ ./test.mjs 
$ ls -1 | wc -l  # Note: This line is zx output.
/bin/sh: 1: set: Illegal option -o pipefail
  at file:///home/hata6502/zx-test/test.mjs:17:8

I think this error is occured by using sh instead of bash.
set -euo pipefail; seems not work in sh.

$ bash
$ set -euo pipefail; echo "test"
test
$ sh
$ set -euo pipefail; echo "test"
sh: 1: set: Illegal option -o pipefail

Steps to Reproduce the Problem

  1. Make test.mjs.
  2. Run chmod +x test.mjs
  3. Run ./test.mjs

Specifications

  • Version: 1.1.0
  • Platform:
    • OS: Ubuntu 20.04
@antonmedv
Copy link
Collaborator

I see. Is there and same option as pipefail is sh?
or maybe make this command not fatal.

@hata6502
Copy link
Author

hata6502 commented May 7, 2021

Sorry! I resolved.

Resolution
Insert $.shell = '/bin/bash' in the top of script file.

Reference: https://github.com/google/zx#shell

@hata6502 hata6502 closed this as completed May 7, 2021
@hata6502
Copy link
Author

hata6502 commented May 7, 2021

Moved to: #21

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

No branches or pull requests

2 participants