Off-Topic > Off-Topic - Tiny Tux's Corner
[Solved] Asking for recomendations on the shell script formatting.
Rich:
Hi CardealRusso
--- Quote from: CardealRusso on July 19, 2023, 05:49:11 PM ---
--- Quote from: Rich on July 19, 2023, 05:36:31 PM ---Don't all languages have some way of marking where a function ends?
--- End quote ---
Certainly. I assume it's a must.... That can be anything from "e n d" ...
--- End quote ---
Didn't you just criticize The constant use of "ends" in a previous post?
--- Quote --- ... to a simple "<return>" or, actually, nothing (assuming it already has a line break) ...
--- End quote ---
I take it you mean a blank line. That would mean no blank lines inside
of functions, and for or while loops, blocks of code in if statements, etc.
CardealRusso:
--- Quote from: Rich on July 19, 2023, 09:14:00 PM ---Didn't you just criticize The constant use of "ends" in a previous post?
--- End quote ---
Hello Rich.
Please allow me to explain what I'm referring to with some examples.
Python:
--- Code: ---for a in range(3):
for b in range(3):
for c in range(3):
for d in range(3):
println("Hello, World!")
--- End code ---
Nim:
--- Code: ---for a in 0..3:
for b in 0..3:
for c in 0..3:
for d in 0..3:
echo "Hello, World!"
--- End code ---
Lua:
--- Code: ---for a = 1, 3 do
for b = 1, 3 do
for c = 1, 3 do
for d = 1, 3 do
println("Hello, World!")
end
end
end
end
--- End code ---
But that's just a point I make, I don't mean that Lua is totally bad for that. In fact, it looks like it has the potential to be the best option, as you have to follow some basic rules of "script yes. not the compiled language" as well as a small binary.
Following these limitations, it seems to me that the second viable option would be QuickJS (which, by the way, the package present in the x64 repository is badly organized, since the libraries are not dependencies of the binaries, there should be "-bin" with qjs only, "-libs" with libraries and "-tools" with qjsc)
Rich:
Hi CardealRusso
I see. So rather than using braces or keywords, they
determine scope through indentation.
I prefer properly indented braces or keywords on their
own lines myself. I don't mind a little extra typing.
mocore:
--- Quote from: GNUser on July 19, 2023, 08:32:44 PM ---I'm arguing against making drastic changes to TCL's infrastructure because of potential stability issues. As it is
>(i.e., powered by shell scripts including some that are a decade old),<
TCL is stable, does absolutely everything I need it to do (and well), and has qualities that make it the only distro that I want to use and contribute to.
--- End quote ---
wrt above quote spesificly bold section i was reminded of a post on the web titled "More shell, less egg"
previously mentioned @ https://forum.tinycorelinux.net/index.php/topic,22762.msg142399.html
http://www.leancrew.com/all-this/2011/12/more-shell-less-egg/ || https://web.archive.org/web/20130209012208/http://www.leancrew.com/all-this/2011/12/more-shell-less-egg/
--- Quote ---Knuth wrote his program in WEB, a literate programming system of his own devising that used Pascal as its programming language.
His program used a clever, purpose-built data structure for keeping track of the words and frequency counts; and the article interleaved with it presented the program lucidly.
McIlroy’s review started with an appreciation of Knuth’s presentation and the literate programming technique in general.
He discussed the cleverness of the data structure and Knuth’s implementation,
pointed out a bug or two, and made suggestions as to how the article could be improved.
And then he calmly and clearly eviscerated the very foundation of Knuth’s program.
What people remember about his review is that McIlroy wrote a six-command shell pipeline
that was a complete (and bug-free) replacement for Knuth’s 10+ pages of Pascal.
--- End quote ---
jazzbiker:
Hi mocore,
You propose the McIlroy's script as an example of the true formatting? Then my initial script is absolutely ok ;-)
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version