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

SC2216: false positive for piping yes or letter y/n to commands that ask yes/no questions. #3141

Open
1 of 4 tasks
astkaasa opened this issue Feb 7, 2025 · 0 comments
Open
1 of 4 tasks

Comments

@astkaasa
Copy link

astkaasa commented Feb 7, 2025

For bugs

For new checks and feature suggestions

Here's a snippet or screenshot that shows the problem:

#!/bin/bash

yes | cp -r dist/* .

Here's what shellcheck currently says:

$ shellcheck myscript
 
[Line 3:](javascript:setPosition(3, 7))
yes | cp -r dist/* .
      ^-- [SC2216](https://www.shellcheck.net/wiki/SC2216) (warning): Piping to 'cp', a command that doesn't read stdin. Wrong command or missing xargs?

$

Here's what I wanted or expected to see:

Here yes is used to pipe y to commands that ask yes/no questions.

Actually echo any word begin with y/n (case insensitive) should be valid too, but it may be too difficult to be exempted from this rule.

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

1 participant