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

Use alternatives to check if a command exists #188

Open
thomasmerz opened this issue Apr 18, 2024 · 1 comment
Open

Use alternatives to check if a command exists #188

thomasmerz opened this issue Apr 18, 2024 · 1 comment

Comments

@thomasmerz
Copy link

Hi Jean-Frédéric,

ich habe deinen Vortrag auf dem CLT24 gesehen und habe mir gedacht, dass es dich interessieren könnte, dass man statt wie in

if (File("$path/$firstWord").existsSync()) {
auch anders, eventuell effizienter herausbekommen kann, ob "$firstWord" ein Befehl ist:

$ type -a zypper
zypper is aliased to `/usr/bin/sudo zypper'
zypper is /usr/bin/zypper

$ type -a züpper
-bash: type: züpper: not found

$ which zypper
/usr/bin/zypper

$ which züpper
which: no züpper in (/home/thomas/bin:/home/thomas/.local/bin:/home/thomas/bin:/usr/local/bin:/usr/bin:/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:/home/thomas/go/bin)

$ hash zypper ; echo $?
0

$ hash züpper ; echo $?
-bash: hash: züpper: not found
1

Ansonsten finde ich deinen Linux-Assistant MEGA!!!! (zumindest für Leute, die mit Linux eher am Anfang stehen - ich bin seit 1992 damit in Kontakt und brauche es daher "leider" nicht mehr 😁 )

@Jean28518
Copy link
Owner

Danke für Deinen Tipp, werde ich umstetzen!

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

No branches or pull requests

2 participants