Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test if command line argument is entered?

Tags:

applescript

For my script, I'm getting an argument from user input on the command line, and I want to make sure the user doesn't forget to input the argument. So basically, I want to make my script do something like this:

on run argv
    if (item 1 of argv exists) then
        return "defined"
    else
        return "undefined"
    end if
end run

Right now the part that says (item 1 of argv exists) does not work, but I hope someone can help me out. Thanks!

like image 443
Jazon Avatar asked Sep 15 '25 03:09

Jazon


1 Answers

on run argv
    if (count of argv) > 0 then
        return "defined"
    else
        return "undefined"
    end if
end run
like image 147
Barmar Avatar answered Sep 17 '25 20:09

Barmar