[DiscordArchive] Why not change `sleep 370` to for example `sleep $((time + 10))` to make it adapt to the specified t
[DiscordArchive] Why not change `sleep 370` to for example `sleep $((time + 10))` to make it adapt to the specified t
Archived author: Revision • Posted: 2022-05-21T20:29:42.449000+00:00
Original source
Why not change `sleep 370` to for example `sleep $((time + 10))` to make it adapt to the specified time?
Archived author: Revision • Posted: 2022-05-21T20:31:11.530000+00:00
Original source
That way you won't have to go through and edit certain sleeps every time you change the time
Archived author: Revision • Posted: 2022-05-21T20:42:34.388000+00:00
Original source
You can also do something like this to simplify things if you want to. The first line is clearly optional as it simply reads the time from the arguments, like `./script.sh 300` would set time to 300. The second line calculates the amount of minutes so you don't have to change it. It wouldn't be hard to throw an if at it to determine if it's minute or minutes but I imagine it's rare to see such a low time.
```
time=$1
timetext="$((time / 60)) minute(s)"
```
Archived author: Revision • Posted: 2022-05-21T20:43:37.749000+00:00
Original source
Of course, if you use arguments - you have to make sure to stop if one isn't given if it's required.
```
if [[ -z $1 ]]; then
exit
fi
```
Archived author: Revision • Posted: 2022-05-21T20:44:29.638000+00:00
Original source
Or set it to a default value if $1 isn't supplied.
Archived author: Revision • Posted: 2022-05-21T21:01:56.112000+00:00
Original source
As a reference, this would be a full check of minute/minutes:
```
time=$1
timetext="$((time / 60))"
[ $time -gt 119 ] && timetext="${timetext} minutes" || timetext="${timetext} minute"
```
Archived author: Tanados • Posted: 2022-05-21T21:47:50.853000+00:00
Original source
Ty for the reply and the advice that you give me. For sure your ideas are better and that will improve the whole code
I add your reference into the script. Are you think I can do something more to be good for all who have no clue how to make something like this.
I like to help others as well as I learn new stuff Like this that you show me I don't now that i can use reference like this for minutes
Archived author: Revision • Posted: 2022-05-21T22:15:04.555000+00:00
Original source
I'm sorry to say I'm not sure what you're asking.