From 6b8cae12cb5d60b37931332d9d8008649ae14566 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 12 Sep 2026 11:31:19 +0300 Subject: feat!: Update dunbar markup Currently the newest version of the markup is not on the main branch, mostly because of polish and the documentation. As an effect from the changes to the language, the sitemap is the only thing which needs to be created externally. --- src/blog/bash-is-weird/index.du | 55 ++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 26 deletions(-) (limited to 'src/blog/bash-is-weird') diff --git a/src/blog/bash-is-weird/index.du b/src/blog/bash-is-weird/index.du index 3fbc2cd..8fe78cf 100644 --- a/src/blog/bash-is-weird/index.du +++ b/src/blog/bash-is-weird/index.du @@ -1,30 +1,31 @@ -# BASH is weird +'def title BASH is weird +'def desc Interesting quirks of BASH -'define expected-reading 4 min -'define created 01 May 2023 -'define edited 02 May 2023 -[$pagenav] +# {title} -'footnote parameter-expansion Of course this is just one of the many ways to reference and work with variables. -For very basic stuff, BASH is decently simple and intuitive, for example variables are set with the format [`name=value`] and they're referenced with [`\$name`] [$parameter-expansion]. -However, that changes once you start diving deeper (as I had to do for my [url /talks/linuxgraphy-by-strabo Linuxgraphy by Strabo] presentation). +{pagenav 4 min;01 May 2023;02 May 2023} + +For very basic stuff, BASH is decently simple and intuitive, for example variables are set with the format {` name=value} and they're referenced with {` $name} {fn Of course this is just one of the many ways to reference and work with variables.}. +However, that changes once you start diving deeper (as I had to do for my {url Linuxgraphy by Strabo;/talks/linuxgraphy-by-strabo} presentation). An example which illustrates my point would be: ```bash +'emplace myvar=($(echo A B C)) myvar=1234 -echo $((myvar += 46)) ${myvar[\${myvar:0:1}]} +echo $((myvar += 46)) ${myvar[${myvar:0:1}]} +'endemplace It has 3 things which really bothered me: :ordered -1. The output of [`\$(echo A B C)`] is replaced "literally", and then the whole expression is evaluated. - Meaning, [`myvar=($(echo A B C))`] turns into [`myvar=(A B C)`], which creates an array with those three letters. +1. The output of {` $(echo A B C)} is replaced "literally", and then the whole expression is evaluated. + Meaning, {` myvar=($(echo A B C))} turns into {` myvar=(A B C)}, which creates an array with those three letters. .p - I thought the "returned" value of [`\$(echo A B C)`] would be the whole string "A B C", so the array would have one element, that string. - However, [`\$()`] isn't really a function, which takes arguments, "creates" commands and returns their output. - It's [url https://www.gnu.org/software/bash/manual/html_node/Command-Substitution.html Command [=Substitution=]], the text gets executed and it's output [=replaces=] the [`\$(...)`] itself (slightly reminiscent of [url https://lispcookbook.github.io/cl-cookbook/macros.html LISP macros]). + I thought the "returned" value of {` $(echo A B C)} would be the whole string "A B C", so the array would have one element, that string. + However, {` $()} isn't really a function, which takes arguments, "creates" commands and returns their output. + It's {url Command {b Substitution};https://www.gnu.org/software/bash/manual/html_node/Command-Substitution.html}, the text gets executed and it's output {b replaces} the {` $(...)} itself (slightly reminiscent of {url LISP macros;https://lispcookbook.github.io/cl-cookbook/macros.html}). .p Side note: obviously, the original expected behaviour can happen if we use some quotes: @@ -32,34 +33,36 @@ It has 3 things which really bothered me: ```bash myvar=("$(echo A B C)") -2. On the second line, [`myvar`] [*becomes*] an integer and then we do an arithmetic operation on it, nothing wrong here. - [`\${parameter:offset:length}`] returns the substring from [`parameter`] from [`offset`] with size [`length`], but we're giving it a "number", so it should either throw some sort of error or return something default, like 0. +2. On the second line, {` myvar} {i becomes} an integer and then we do an arithmetic operation on it, nothing wrong here. + {` $\{parameter:offset:length\}} returns the substring from {` parameter} from {` offset} with size {` length}, but we're giving it a "number", so it should either throw some sort of error or return something default, like 0. However it correctly returns the number 1 (and no, that isn't a default, the number is correctly parsed as a string). .p This shows that numbers are actually strings too, and numerical operations are just weird string operations. - Contrary to any dynamically-typed language, it's not like the type of a variable is inferred from it's value, [url https://tldp.org/LDP/abs/html/untyped.html there isn't a type at all]! - Which makes everything even more weird, considering you [*can*] [url https://www.gnu.org/software/bash/manual/bash.html#index-declare create variables with a specific type]. + Contrary to any dynamically-typed language, it's not like the type of a variable is inferred from it's value, {url there isn't a type at all;https://tldp.org/LDP/abs/html/untyped.html}! + Which makes everything even more weird, considering you {i can} {url create variables with a specific type;https://www.gnu.org/software/bash/manual/bash.html#index-declare}. -3. Finally, the arguably biggest weirdness of it all, is [`\${myvar[1]}`]. - It doesn't matter how it is represented, at first [`myvar`] was the list of values A, B, C and now it's a number, this should return nothing. - Per contra, the value [`B`] is returned instead! +3. Finally, the arguably biggest weirdness of it all, is {` $\{myvar[1]\}}. + It doesn't matter how it is represented, at first {` myvar} was the list of values A, B, C and now it's a number, this should return nothing. + Per contra, the value {` B} is returned instead! .p - Via trial and error, we find that our number will be returned when the index is 0, and with index 2 we get [`C`]. + Via trial and error, we find that our number will be returned when the index is 0, and with index 2 we get {` C}. So all variables are arrays, and by default for integer and string operations, the first value is used? .p - This is strange, but it cannot be the full picture, because [url https://linux.die.net/Bash-Beginners-Guide/sect_10_01.html names have attributes], alongside it's type, a variable (name) can be read-only, but also have the "trace" flag, which only works with functions. + This is strange, but it cannot be the full picture, because {url names have attributes;https://linux.die.net/Bash-Beginners-Guide/sect_10_01.html}, alongside it's type, a variable (name) can be read-only, but also have the "trace" flag, which only works with functions. So, variables and functions are the same "object"? Unfortunately, I couldn't find any definitive information on the topic, so this train of thought will have to be left unresolved. -And this is just one example, more bizarreness can be found with [url https://www.vidarholen.net/contents/blog/?p=25 square brackets] and [url https://mywiki.wooledge.org/BashPitfalls most ok looking code]. -[url https://chrisdone.com/posts/shell-conduit/ Some people] even go as far to say: +And this is just one example, more bizarreness can be found with {url square brackets;https://www.vidarholen.net/contents/blog/?p=25} and {url most ok looking code;https://mywiki.wooledge.org/BashPitfalls}. +{url Some people;https://chrisdone.com/posts/shell-conduit/} even go as far to say: .quote Its syntax is insane, incredibly error prone, its defaults are awful, and it’s not a real big person programming language. -But I believe that is a step too far, [url http://www.binaryphile.com/bash/2018/07/26/approach-bash-like-a-developer-part-1-intro.html there are benefits, especially when approaching it seriously]. +But I believe that is a step too far, {url there are benefits, especially when approaching it seriously;http://www.binaryphile.com/bash/2018/07/26/approach-bash-like-a-developer-part-1-intro.html}. Every language has mind-numbing oddities, some get the out of the way from the start (like BASH), and others much later. + +{footnotes} -- cgit v1.3.1-26-gb76a From 3bf2c2004c1c3ea1748983247e1fcf12913d587f Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 14 Sep 2026 11:39:40 +0300 Subject: feat(src): Final markup fixes and dunbar update --- dunbar | 2 +- src/INIT.du | 17 +++++- src/blog/bash-is-weird/index.du | 5 -- src/blog/connect-to-mysql-in-dotnet-ef/index.du | 4 +- src/blog/fix-no-frame-buffer-plan9/index.du | 1 - src/blog/fix-qc-timeout/index.du | 4 -- .../index.du | 2 - .../index.du | 25 +++----- src/blog/how-to-encrypt-email/index.du | 6 +- .../index.du | 5 +- .../install-drivers-for-epson-scanners/index.du | 4 +- .../managing-apps-with-adb-without-root/index.du | 8 +-- .../mundus-first-shot-at-gamedev/basic-concepts.du | 4 +- src/blog/mundus-first-shot-at-gamedev/timeline.du | 6 +- .../mundus-first-shot-at-gamedev/user-interface.du | 2 +- src/blog/plan9-in-linux-mouse-menus/index.du | 8 +-- .../sane-explanation-of-compilers/part-1/index.du | 71 +++++++++++----------- src/blog/taming-the-fun-too/index.du | 10 +-- .../index.du | 32 ++++------ src/blog/turn-off-notifications-windows/index.du | 2 - src/blog/virt-manager-freeze-on-browse/index.du | 6 +- src/blog/windows-run-dialog/index.du | 4 +- src/teaching/oop-2023/week1/good-software.du | 2 + src/teaching/upp-2023/week12/index.du | 8 ++- src/teaching/upp-2025/week13/index.du | 2 +- 25 files changed, 116 insertions(+), 124 deletions(-) (limited to 'src/blog/bash-is-weird') diff --git a/dunbar b/dunbar index eaa4cb0..efb7d51 160000 --- a/dunbar +++ b/dunbar @@ -1 +1 @@ -Subproject commit eaa4cb0123bcf01056d4dc400f2c3e513f41e967 +Subproject commit efb7d51a645b0038e22eabbe494ddc0598962458 diff --git a/src/INIT.du b/src/INIT.du index d03720a..02e6eff 100644 --- a/src/INIT.du +++ b/src/INIT.du @@ -162,19 +162,32 @@ desc - Page description 'cmdprocess code {if {LANG};highlight -O html -f -S {default {normalise {LANG}};text};cat} 'endif +'let start {unordered}default

+'let end {unordered}default

+'let start {ordered}default

+'let end {ordered}default

+ ## Attention 'let start question
question 'let end question
+'let start {question}default

+'let end {question}default

'let start warn
warn 'let end warn
+'let start {warn}default

+'let end {warn}default

'let start important
important 'let end important
+'let start {important}default

+'let end {important}default

'let start note
'let end note
+'let start {note}default

+'let end {note}default

## Headers @@ -339,6 +352,8 @@ url href # Substitutions +'def fn_ref {sup {1}} + 'def due_for_rework {url {b {i Due for rework}};/rework.html} 'def nohtml {greplace {1};<;<\;} @@ -363,7 +378,7 @@ reading created edited -'def breadcrumb » {def x/...;{>= {count {1};/};1}}{if {x/...};{url {substrBefore {1};/};{default {2};./}};{italic {substrAfter {1};/}}} {{if {x/...};breadcrumb;none} {substrAfter {1};/};{substrAfter {2};../}} +'def breadcrumb » {def x/...;{>= {count {1};/};1}}{if {x/...};{url {substrBefore {1};/};{default {2};./}};{italic {1}}} {{if {x/...};breadcrumb;none} {substrAfter {1};/};{substrAfter {2};../}} 'def pagenav