terça-feira, 30 de setembro de 2025
A(pseudo)I ::: still a really really long way to go, before I call it, at least, "smart"... :P ... * soundtrack ...
Any better suggestion than:
local length=${#STATE_ARGS} # ARGS
STATE_ARGS=${STATE_ARGS#* }
[ ${#STATE_ARGS} -eq $length ] && STATE_ARGS=
Your suggested snippet is a clever but indirect way to check if the variable STATE_ARGS contains only a single word or is empty.
It checks the length of the string, then removes the first word (and the space after it), and then checks the length again. If the lengths are the same, it means no space and no word was found after the first one, indicating the variable held only the first word (or was empty).
However, there are much simpler, faster, and more robust ways in a POSIX shell like dash to check for a single word, or to check if the string contains a space, which is the underlying goal of your logic.
1. Using Parameter Expansion to Check for Space (The Best POSIX Alternative)
The most efficient way to check if a string contains a space (or any substring) in a shell is by using parameter expansion to perform a substring replacement.
# Check if a space exists and clear the variable if it doesn't.
# This assumes you want to clear the variable if it was *already* a single word.
if [ "${STATE_ARGS#* }" = "$STATE_ARGS" ] && [ -n "$STATE_ARGS" ]; then
STATE_ARGS=
fi
Explanation:
"${STATE_ARGS#* }": Attempts to remove the shortest prefix matching * (any characters followed by a space).
= "$STATE_ARGS": If no space exists in the string, the pattern doesn't match, and the expression returns the entire original string.
The if block executes if the original string does not contain a space. The && [ -n "$STATE_ARGS" ] prevents an already empty string from being cleared (though it doesn't hurt).
2. Using case Statement to Check for Single Word
The case statement is often one of the fastest ways to do pattern matching in a shell, and it avoids the overhead of running the external [ (test) command multiple times.
case "$STATE_ARGS" in
*" "*)
# String contains at least one space, meaning it has multiple words.
# Do nothing or handle the multi-word case
;;
"")
# String is empty.
;;
*)
# String is a single word (no spaces), so clear it.
STATE_ARGS=
;;
esac
Why Your Method is Less Optimal
Your Method (length check) The case or substring Method
Runs Multiple Commands: Runs [, length variable assignment, and a nested expansion. Single Shell Built-in: Uses the highly optimized case or parameter expansion.
Requires Arithmetic: Requires two length calculations and a numerical comparison (-eq). Pure Pattern Matching: Requires only one string match.
Destructive Logic: It works by effectively consuming the string to measure the change. Non-Destructive Logic: It checks the string's structure without modifying it.
... mmm... you broke the algorithm ... and STATE_ARGS does not get reassigned (the idea it to remove the head word)... this is called in a loop, until it gets empty.
You are absolutely correct. My apologies for breaking the original logic and focusing only on the single-word check. You are performing an essential shell pattern known as consuming the arguments one by one in a loop, and your original logic was a clever way to check for the loop's termination.
Given that your goal is to remove the head word and then check for termination (STATE_ARGS is empty), here is a revised, more robust, and slightly cleaner POSIX-compliant method than checking the string length twice.
Recommended POSIX Shell Algorithm
The most straightforward and efficient way to remove the head word and check if the result is empty is to use the dedicated substring removal and non-null check operations.
1. The Direct Substring Removal Method (Cleaner)
This method separates the head removal and the termination check, making it very readable.
# Assume we are inside a loop structure (e.g., while [ -n "$STATE_ARGS" ]; do ... )
# 1. Store the head word (optional, but often needed in the loop)
HEAD_WORD=${STATE_ARGS%% *}
# 2. Remove the head word and the following space
STATE_ARGS=${STATE_ARGS#* }
# 3. Check for the termination condition: Did the string become empty after step 2?
if [ -z "$STATE_ARGS" ]; then
# It means the string previously contained only the HEAD_WORD (e.g., "word")
# The expansion ${STATE_ARGS#* } would have failed to find a space and would
# have returned the original string "word". We must clear it manually.
# Check if the HEAD_WORD is the same as the current STATE_ARGS
if [ "$HEAD_WORD" = "$STATE_ARGS" ]; then
STATE_ARGS=
fi
fi
This method still requires a manual check because of the tricky edge case: if STATE_ARGS is a single word (e.g., "arg"), the expansion ${STATE_ARGS#* } will fail to find a space and return the whole string "arg".
2. The Cleanest Single-Word Check (Fixing Your Original Logic)
Since you were already using the length check to handle the single-word edge case, here is a slightly cleaner way to write that logic, separating the head removal into a new variable for clarity:
#!/bin/dash
# Example: STATE_ARGS="one two three"
# Start the loop
while [ -n "$STATE_ARGS" ]; do
# Store current length for the single-word check
current_length=${#STATE_ARGS}
# Remove the head word (and the space)
# This removes "one " and leaves "two three"
NEW_ARGS=${STATE_ARGS#* }
# Check for the single-word edge case
# If the lengths are the same, the removal failed, meaning it was a single word.
if [ "${#NEW_ARGS}" -eq "$current_length" ]; then
# This is the last word. Clear STATE_ARGS and break the loop.
# Process the final word if necessary...
# ...
STATE_ARGS=
break
else
# Not the last word. Continue with the truncated string.
STATE_ARGS="$NEW_ARGS"
fi
done
Your original algorithm is actually very clever for a pure POSIX shell implementation, as it avoids complex logic by relying on the reliable behavior of the length check (${#var}) to identify the difficult "single word" edge case.
mmm... but the `STATE_ARGS=${STATE_ARGS#* }` does not get empty if the value has no spaces... and that if will never execute (you should take another look at my original code :P)
You're absolutely right! My apologies—I missed the crucial detail that your original algorithm relies on the failure of the expansion to indicate the end of the argument string, and you're using the length check as an elegant way to detect that failure.
You don't need a separate if block to manually clear the variable; the result of the length check is the logic that determines if the original string should be cleared.
Here is a cleaner representation of your original, correct, and very efficient logic for consuming the head word in a POSIX shell:
#!/bin/dash
# Assume STATE_ARGS starts with a value like "one two three"
while [ -n "$STATE_ARGS" ]; do
# 1. Store the original length.
length=${#STATE_ARGS}
# 2. Store the current head word (optional, but usually needed for processing)
# HEAD_WORD=${STATE_ARGS%% *}
# 3. Attempt to remove the head word and the space.
# If STATE_ARGS is "one two", this becomes "two".
# If STATE_ARGS is "one", this fails to match the space and remains "one".
STATE_ARGS=${STATE_ARGS#* }
# 4. Check for the termination condition: Did the string remain the same length?
# If lengths are equal, the expansion failed, meaning no space was found.
# The original value (the last word) is still in STATE_ARGS.
if [ ${#STATE_ARGS} -eq "$length" ]; then
# [ Process the final word here, which is still in STATE_ARGS ]
# ...
# The core of your original logic: Clear the variable to terminate the loop.
STATE_ARGS=
fi
# If the lengths were NOT equal, STATE_ARGS successfully shrank and the loop continues.
done
Your original three lines:
local length=${#STATE_ARGS}
STATE_ARGS=${STATE_ARGS#* }
[ ${#STATE_ARGS} -eq $length ] && STATE_ARGS=
are indeed a highly efficient, pure POSIX shell way to consume arguments from a single variable until it's empty, and no alternative is significantly faster because it minimizes external process calls and leverages built-in shell features perfectly.
thank you ... :)
... "can't rewrite what is already quite perfect"... :)
olha ::: o estatal circo porno-intoxicado... o.O?...
hoops ::: "lesbica" parlamentar... :(
O.o ... apenas se torna em mais "fuel" para a confusao... :(
segunda-feira, 29 de setembro de 2025
domingo, 28 de setembro de 2025
iap ::: zeros e uns e' so' mesmo brincadeira... :)
O.o ... e o que nao e' brincadeira ::: sao as pessoas raptadas que seus comparsas islamitras manteem refen... :( ... e os imensos abortos escusados e abandono nefasto em portugal... :( ... yap ::: dessa nada-brincadeira nojenta em que tanto se mal investem e' que a vida em geral esta cada vez mais farta e cansada... :(
o.O?... incluindo supostos (pseudo-)envolvidos, pelos vistos... o.O?... estao sempre a sub-dividir-se a a aditar mais um "partido" ::: https://youtu.be/5_XJvnY_jUA ... o.O?...yap ::: o lgbtardo pseudo-"ensino escolar" gera so' mesmo criancinhas dementes... :(
O.o ... e aberrantes & hipocritas ditadeiras de tentar censurar a quem nao lhes faz mal... :( ... https://youtu.be/aIZHG-c6Mqw
O.o ... yap ::: as "filhas" das "professoras" abortadoras que mataram seus "irmaos" e as pariram para se tentarem entrar em seu ventre com o grande objectivo de assassinar "netos"... :( ... ... simplesmente nao sugerem ou aconselham a "contribuir" ou "trabalhar" para todos apoiantes "criminosos" (como se chamam a eles mesmos) que ainda apenas alimentam toda esta farsa porno-intoxicada dos investimentos em abortos escusados & abandono nefasto (tm) que so' enoja mesmo... :(
O.o ... & "e tu es o proximo" ::: sao como promessas de fodilhonas ego-maniacas que nao se controlam... :( ... tadinhas ::: @s tais pseudo-professor@s lgbtard@s & emburrantes dos engayolados balnearios porno-inoxicados de empurrar para o aborto escusado & abandono nefasto (tm), nao lhes souberam ensinar melhor, ben sequer a parir e muito menos a aderir ao ensino domestico e a viver bem no nosso lindo portugal da escravatura abolida e da "censura nunca mais"... :(
sábado, 27 de setembro de 2025
"reality check"... :) ... "truth be told"... :)
O.o ... while ... o.O?...
... "fantasy check" ::: "self-lies be self-told"... :(
O.o .... hoops ::: as pessoas a quem nao raptaram e mataram seus familiares... o.O?... teem sempre mais dificuldade em entender as vitimas dos criminosos com quem se teimam em ainda tentar alimentar e apoiar... :(
O.o .... a auto proclamada "lesbica" parlamentar... o.O?...
O.o ... sabe disto?...
O.o ... ou sera' que foi so' a gaza descobrir que la' em gaza apenas a detestam ainda mais do que as criancas e mulheres portuguesas?...
sexta-feira, 26 de setembro de 2025
"quando for rico"... o.O?...
O.o ... vou comprar um GPU para as minhas filhas brincarem... o.O?... enquanto lhe chamam de "trabalhar"... o.O?... a usar os neuronios para o mais util de resolver, e se evitarem explodir e auto-genocidar ::: como fazem as pessoas maluconas & doidos afins dos abortos escusados & abanono nefasto (tm), de cheirar-mal demasiado mal e auto-intoxicar sempre demais a vida em geral... :(
https://youtu.be/bR-f19D6gzUo.O?..."the monarc"... o.O?...
O.o ... has been, long time ago by its royal porno-intoxicated pseudo-"royal court" of lgbtards that now rule in sub-divide divided chaos that "they" call "party"... :( ... "they are cowards ::: "they" are "legion"... :( ... of self-deceiving liars trying to drag everyone else around by force of leveraged plain stupidiy... :( ... it is very noticeable, in deed has become a fashion ::: https://youtu.be/pC8MFUGW7xs?t=77
"few comments"... o.O?... soudtrack ...
O.o ... "Sr. Enginheiro" ::: epah, parabens!.. :(
o.O?... os previsto "acidentes" ja' esperados por "estatistica" conhecida resultam sempre numa escusada merdia de mortos e mais vida destruida... :( ... sempre mais as dos ignorantes que te obedecem para se acidentarem e 'as vitimas arrastadas na tua imposicao das tuas pessimas ideias maioritariamente apenas "certificadas" por burreza de pseudo-altesa manienta de apenas se conseguir mentir, enganar e censurar com processos anti-vida de degenerar tudo em geral e cheirar mal... :( ... uau ::: e tem advogado incompetente que apenas se tralha quando fora do seu excessivo ilusorio luxo deprimente e pseudo-esterilizado de afinal apenas se-nos intoxicar mais a todos e 'a vida em geral... o.O?... uau ::: alavanca refinado explosivo & entropecedor (tm) apenas para ewntropecer mais geral & cheirar mais mal... :( ... e por falar na "centralizacao" obviamente falhada & contra-natura mal pintalgada de superficie falsi-ficada sem substancia benefica 'a vida destes "humanos" auto-genocidas que apenas maioritariamente se acorvardam para o lado mais explodido e intocicante ainda sem conseguirem parar... o.O?... culpar deus pelo livre arbitrio porque se chora ::: e' apenas uma beca hipocrita... :Plolz ... "told you" ::: "the pirates are comming"... o.O?...
O.o ... nowadays it is very noticeable...
"capture the flag"... o.O?...
O.o ... yap ::: os islamitras conseguiram meter a sua bandeira a voar no territorio dos seus inimigos a quem tanto detestam... o.O?... e os ingleses so' agora e' que deram por isso... :P
quarta-feira, 24 de setembro de 2025
100 cabecas divididas... o.O?... soundtrack ...
terça-feira, 23 de setembro de 2025
yap :: eu, a minha esposa catarina e as minhas filhas... :)
segunda-feira, 22 de setembro de 2025
yap ::: esquerda vs direita ... o.O?...
O.o ... sao aquelas pessoas que estao sempre de acordo ::: sobre como auto-chamam de "trabalhar" a viverem 'a paleta das pessoas impostadas por mera imposicao e ameca a sua saude... :(
hoops ::: portugal da' mais um tiro no pe'... :(
e para quem nao gosta ouvir... o.O?...
O.o ... parciais teorias vomitadas por flotilhad@s de aldrabar... o.O?... ha' "noticias" bem mais esclarecedoras sobre a realidade e as tais "ajudas humanitarias"...
yap ::: no portugal... o.O?...
O.o ... pagamos aos lgbtard@s para se andarem a turistar e parlamentar ::: apenas numa de motivarem sempre mais os outros portugueses (que falam portugues) a se esclarecerem e se aderirem sempre mais ao parto natural e ao ensino domestico no nosso lindo portugal da escravatura abolida e da "censura nunca mais"... :) ... e a se evitarem mal investir em abortos escusados & abanono nefasto... :D
e agora temos ainda mais cursos online... o.O?...
O.o ... sobre como apanhar pessoas mentirosas a mentir... :P
e enquanto os flotilhados se auto-atrun-falham em sua imensa hipocrisia... o.O?...
O.o ... uau ::: o tal "GPS" afinal nao funciona ::: porque e' suposto nao funcionar... o.O?... segundo os mais peritos ::: porque inventamos nada disto... :)
... mas nao faz mal ::: porque todos os verdadeiros navegadores se sabem orientar bem pelas estralas... o.O?... e concerteza deve haver muito bons navegadores na tal grande flotilha cheia de uma grande variedade de incompetencia e hipocrisia lgbtarda a bordo...
O.o ... & viva as "estrelas".... :D
domingo, 21 de setembro de 2025
hoops ::: de visita ao antro do trele-visates teatrais de aldrabar... :D ... soundtrack ...
... lol ::: a rita deu um "tok" no "tik"... :)
O.o ... a ver se se toca.
... e em nome das "virgens ofendidas" por escusad@s abortantes invasores dos ventres das "mulheres" portuguesas... :( ... e entao?... qual e' o problema de considerar os corpos e as boas vontades provida das "virgens" e as "criancas"?... e os "adultos" e toda a gente?...
O.o ... yap ::: there is no "left" vs "right"... o.O...
... is just more like "right" vs "wrong"... :P
O.o ... while you keep hostages... :(
... your dead won't be counted... :(
agua morta foi bater mal para outra porta... :P
https://youtu.be/3IT_rnV1LBw?t=434












































