[Slackbuilds-users] Using something other than bash for rc scripts?
Didier Spaier
didier at slint.fr
Sat May 11 09:51:13 UTC 2024
More generally, as specified by POSIX:
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_04
Thus most of the operations listed in
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap01.html#tag_17_01_02_01
are available in any POSIX-compliant shell.
Also, taking the risk of beating a dead horse, I suggest using only the
features specified by POSIX, and not bash specific ones, for the sake of
portability.
Cheers,
Didier
Le 11/05/2024 à 10:04, KB_SBo a écrit :
> On 5/9/24 13:00, Charadon via SlackBuilds-users wrote:
>
> re: bash
>> lack of simple arithmetic
>
>
> For integer arithmetic:
>
> $ declare -i a=2+2
> $ echo $a
> 4
> $ let b=9+6 ; echo $b
> 15
> $ echo $((2*5+1))
> 11
>
> or maybe use
>
> $ expr 2 + 3
> 5
>
> and if you want to get really fancy, use the bc command for floating
> point, functions, loops, and algebra:
>
> $ echo "for(i=1; i<=10; i++) {scale=4;sqrt(i);}" | bc
> 1
> 1.4142
> 1.7320
> 2.0000
> 2.2360
> 2.4494
> 2.6457
> 2.8284
> 3.0000
> 3.1622
>
> bash shell can indeed do a bit of arithmetic, and more.
>
> -KB
>
>
> _______________________________________________
> SlackBuilds-users mailing list
> SlackBuilds-users at slackbuilds.org
> https://lists.slackbuilds.org/mailman/listinfo/slackbuilds-users
> Archives - https://lists.slackbuilds.org/pipermail/slackbuilds-users/
> FAQ - https://slackbuilds.org/faq/
>
More information about the SlackBuilds-users
mailing list