Open AlfredWJ opened 10 months ago
- stat=($(< /proc/self/stat))
- base_stime=${stat[21]}
+ base_stime=$(cat /proc/self/stat | cut -d" " -f22)
This is not equivalent, old code returns stime for the script while the new one returns the time for the "cat". You probably want cat /proc/$$/stat.
- stat=($(< /proc/self/stat)) - base_stime=${stat[21]} + base_stime=$(cat /proc/self/stat | cut -d" " -f22)
This is not equivalent, old code returns stime for the script while the new one returns the time for the "cat". You probably want cat /proc/$$/stat.
yes,you are right
In some scenarios, scripts are executed using busybox/bash in the system environment, which does not support string subscripting. When encountering string subscripting, an error will be reported. For example,the following code will result in an error message 'syntax error: bad substitution' when executed.
Can we modify it to the following?