Timeline for How can I switch execution of a command run with specific arguments with another command, but not for other arguments?
Current License: CC BY-SA 4.0
14 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jan 29, 2021 at 11:35 | comment | added | muru |
@KevinC of course you can, you put it another directory in $PATH which comes before the directory where this command is. Typically programs from packages go in /usr/bin or /bin; and /usr/local/bin is very commonly used for overriding programs in those.
|
|
| Jan 29, 2021 at 11:33 | history | edited | muru | CC BY-SA 4.0 |
edited title
|
| Jan 29, 2021 at 11:31 | vote | accept | Kevin C | ||
| Jan 29, 2021 at 11:29 | history | edited | Kevin C | CC BY-SA 4.0 |
added 141 characters in body
|
| Jan 29, 2021 at 11:28 | comment | added | Kevin C | I can't. What if the package of command is updated? It will simply replace the file. | |
| Jan 29, 2021 at 11:21 | answer | added | pLumo | timeline score: 4 | |
| Jan 29, 2021 at 11:21 | comment | added | berndbausch |
Write a shell script named command, which checks if options are -a restart. If yes, it does its custom thing, if no, it calls the original command and passes all options to it. You move the original command to an obscure directory and the shell script into a directory in PATH.
|
|
| Jan 29, 2021 at 11:12 | comment | added | Kevin C |
Sorry, I misunderstood. Only the root user should be fine. When command -b something -a reload is executed, it should execute command -b something -a reload. However, command only takes a single argument, so it won't really matter.
|
|
| Jan 29, 2021 at 11:06 | comment | added | terdon♦ |
What does that mean? Should it print an error? Should it run command -b something -a reload instead? Do you mean that the specific command you are thinking of doesn't allow more than one option to be passed? Also, who should this work for? Anyone on the system who runs command? Only one specific user?
|
|
| Jan 29, 2021 at 11:05 | comment | added | Kevin C | that won't work. | |
| Jan 29, 2021 at 11:05 | history | edited | terdon♦ | CC BY-SA 4.0 |
deleted 1 character in body; edited tags
|
| Jan 29, 2021 at 11:04 | comment | added | pLumo |
what if it is e.g. command -b something -a restart ?
|
|
| Jan 29, 2021 at 11:03 | history | edited | Kevin C | CC BY-SA 4.0 |
added 11 characters in body
|
| Jan 29, 2021 at 10:57 | history | asked | Kevin C | CC BY-SA 4.0 |