Timeline for Forcing an 'added' alias to every command
Current License: CC BY-SA 4.0
5 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Sep 2, 2020 at 15:37 | comment | added | wjandrea | @Scott (1) I can't reproduce the behaviour with numbers or special characters on Bash 4.4 on WSL Ubuntu 18.04. And of course, I also can't reproduce the behaviour with %s, but it turns out C89 doesn't provide %s, so I guess you can't rely on it. I'm not sure how to fix that. Use GNU strftime I guess? | |
| Sep 2, 2020 at 15:23 | comment | added | wjandrea | @Scott (2) No, I said it accommodates empty commands, meaning it keeps printing the previous value, instead of calculating the time again, incorrectly, like Gilles's method does. I wanted it like that so my PS1 can print the current command number and previous time together. But you could easily modify it to not print the time if it's already in the array. Just move the printf inside the if block. | |
| Sep 1, 2020 at 23:18 | comment | added | Scott - Слава Україні | (Cont’d) … Actually, typing a number as a command (e.g., 500000000 -R) interferes amusingly with your code, and some other things (e.g., a command that begins with ., -, * or /, or that contains quoted character(s)) cause it to throw errors. (2) You say that your answer doesn’t issue reports for empty commands, but when I hit Enter (in another system, where %s works), I get “Last command time: nn”, where nn repeats the value from the last non-blank command. | |
| Sep 1, 2020 at 23:18 | comment | added | Scott - Слава Україні | (1) An earlier draft of this comment began “Today I learned that Bash version 4.1 doesn’t support %s in HISTTIMEFORMAT. But I dug a little deeper, and discovered that that’s not quite right. My five-year-old installation of Cygwin came with a version of strftime that doesn’t support %s; therefore, it doesn’t work in Bash. (Although, curiously, date +%s does work.) The good news is that your answer doesn’t care. The bad news is that your answer doesn’t notice, and reports things like “Last command time: 1598908445”. … (Cont’d) | |
| Aug 29, 2020 at 22:04 | history | answered | wjandrea | CC BY-SA 4.0 |