From 912eeb478bb5f3d178f3c8dc8fd78387b523b3e3 Mon Sep 17 00:00:00 2001 From: Malin Freeborn Date: Sat, 16 Sep 2023 18:10:04 +0200 Subject: [PATCH] place posix shell warnings --- system/bash_tricks.md | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/system/bash_tricks.md b/system/bash_tricks.md index 67226ef..c1e05b7 100644 --- a/system/bash_tricks.md +++ b/system/bash_tricks.md @@ -1,6 +1,6 @@ --- -title: "Terminal Tips" -tags: [ "Documentation", "System" ] +title: "bash tips" +tags: [ "Documentation", "Shell", "POSIX" ] --- ## Track Live Changes @@ -67,6 +67,18 @@ Add number to variables with: `((n--))` works identically. +### POSIX WARNING + +The number commands above work in `bash`, but not in bare-ass POSIX shells, such as `dash`. + +Instead, you might do: + +```sh +x=2 +x=$(( x +1 )) +x=$(( x*x )) +``` + ## Finding Duplicate Files ```bash @@ -97,3 +109,8 @@ That gives you a random directory to mess about in. cd $dir ``` +### POSIX WARNING + +These smart-brackets are a bash feature. +If you try to use `{A..Z}` in dash, it will think of this as a single item. +