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

Expression (if,while) get command exit code '{ }' to support redirection to /dev/null or no output at all #113

Open
c-pointer opened this issue Nov 3, 2024 · 2 comments

Comments

@c-pointer
Copy link

I don't know if it is bug or enhancement but

This works

if ( { ping -c 1 -w 1 192.168.0.1 } ) then
  echo "LAN is up"
endif

This does not works (works but redirection does not)

if ( { ping -c 1 -w 1 192.168.0.1 >& /dev/null } ) then
  echo "LAN is up"
endif
@suominen
Copy link
Member

suominen commented Nov 4, 2024

Alternative approaches:

ping -c 1 -w 1 192.168.0.1 >& /dev/null && echo "LAN is up"

or

ping -c 1 -w 1 192.168.0.1 >& /dev/null
if ( $? == 0 ) then
  echo "LAN is up"
endif

@zoulasc
Copy link
Member

zoulasc commented Nov 8, 2024 via email

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

3 participants