Command Vs Which

Discussion in 'Developers' Forum' started by ahrasis, Jan 10, 2022.

  1. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    When one of the scripts I intend to use warn me about this "/usr/bin/which: this version of `which' is deprecated; use `command -v' in scripts instead." in unstable-forth-coming Debian, I googled out and found some 'saying' about using command and which in stackoverflow.

    I realized ISPConfig use quite a lot of which in its software, so should this be changed?
     
  2. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    I usuall use type instead of which. Type is a builtin command in bash shell. I like to add the -a parameter, to print all the commands found with that name.

    Code:
    $ LANG=C type -a type
    type is a shell builtin
    [email protected]:~
    $ LANG=C type -a which
    which is /usr/bin/which
    which is /bin/which
    [email protected]:~
    
     
  3. Jesse Norell

    Jesse Norell ISPConfig Developer Staff Member ISPConfig Developer

    Looks like it wouldn't hurt.
     
  4. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    It (which) will actually be depcrecated if it still hasn't especially in the new forthcoming version of Debian or Ubuntu that I have tested.

    By what I have read so far, command -v is the correct way and that is most probably why which is being deprecated.

    Easy to find and fix but it is up to ISPConfig developer to decide since most coders always say, don't fix what is not broken (yet). :rolleyes:
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    We can change it to 'command -v' in ISPConfig.
     
    ahrasis likes this.

Share This Page