Re: [dev] Preprocessor

2019-05-03 Thread Adrian Grigore
In HTML5, attribute quotes are optional so I'm going to remove all sanitization. On Thu, May 2, 2019 at 3:44 AM Adrian Grigore wrote: > > In the code itself as in compile your own `pp.c`. > > On Thu, May 2, 2019 at 2:45 AM Adrian Grigore > wrote: > > > > I sanitized double-quotes because they ha

Re: [dev] Preprocessor

2019-05-02 Thread Piotr Oleskiewicz
Hi, I really like the project's scope & execution! > Or that it's better done with a few lines of awk. It has been done actually, see http://werc.cat-v.org/docs/rc-template-lang (implementation: https://code.9front.org/hg/werc/file/92f7463dac1a/bin/template.awk). Best wishes, Piotr

Re: [dev] Preprocessor

2019-05-02 Thread Sijmen J. Mulder
Hi Adrian, Adrian Grigore wrote: > I built a preprocessor. It allows embedding shell code in any type of files. A tool like this has been on my mind for a while but in a different form: a more generic template-to-code tool that turns the literal parts of a template into print statements: <

Re: [dev] Preprocessor

2019-05-01 Thread Adrian Grigore
In the code itself as in compile your own `pp.c`. On Thu, May 2, 2019 at 2:45 AM Adrian Grigore wrote: > > I sanitized double-quotes because they have a high frequency in HTML files and > you would have to do lots of escaping. I was also playing with HTML files > while > developing. > > I saniti

Re: [dev] Preprocessor

2019-05-01 Thread Adrian Grigore
I sanitized double-quotes because they have a high frequency in HTML files and you would have to do lots of escaping. I was also playing with HTML files while developing. I sanitized backticks before "$()" are the POSIX preferred method for command substitution. Rest are normal POSIX sh(1) strings

Re: [dev] Preprocessor

2019-05-01 Thread Teodoro Santoni
Hi, 2019-05-01 18:21 GMT, Adrian Grigore : > I think it's done: > > http://adi.tilde.institute/tmp/pp.c > > > > On Thu, Apr 25, 2019 at 6:44 AM Adrian Grigore > wrote: >> >> Ok, refactored. >> >> http://adi.tilde.institute/tmp/pp.c >> >> Sorry, was experimenting before. >> >> On Wed, Apr 24, 2019

Re: [dev] Preprocessor

2019-05-01 Thread Adrian Grigore
I think it's done: http://adi.tilde.institute/tmp/pp.c On Thu, Apr 25, 2019 at 6:44 AM Adrian Grigore wrote: > > Ok, refactored. > > http://adi.tilde.institute/tmp/pp.c > > Sorry, was experimenting before. > > On Wed, Apr 24, 2019 at 11:58 PM opal hart wrote: > > > > On Tue, 23 Apr 2019 12:26

Re: [dev] Preprocessor

2019-04-24 Thread Adrian Grigore
Ok, refactored. http://adi.tilde.institute/tmp/pp.c Sorry, was experimenting before. On Wed, Apr 24, 2019 at 11:58 PM opal hart wrote: > > On Tue, 23 Apr 2019 12:26:04 -0400 > Cág wrote: > > http://porkmail.org/era/unix/award.html > > `ls | cat` is actually useful to combat the differences bet

Re: [dev] Preprocessor

2019-04-24 Thread opal hart
On Tue, 23 Apr 2019 12:26:04 -0400 Cág wrote: > http://porkmail.org/era/unix/award.html `ls | cat` is actually useful to combat the differences between implementations of ls(1) and ensure a one-column, uncoloured list -- wowaname

Re: [dev] Preprocessor

2019-04-23 Thread Hadrien Lacour
On Tue, Apr 23, 2019 at 12:44:57PM -0700, Evan Gates wrote: > On Tue, Apr 23, 2019 at 12:42 PM Hadrien Lacour > wrote: > > That was just shitposting. I use `find` to avoid most of the UNIX > > braindamage > > in this case. > > Which is good as long as you use -exec correctly. Or if you're going >

Re: [dev] Preprocessor

2019-04-23 Thread Adrian Grigore
Ignore the shell stuff, I know it's bad (I also usually use find(1) for these cases), good comments however. It's good you mentioned it so anybody reading this would know it's bad, thank you! On Tue, Apr 23, 2019 at 11:07 PM Peter Nagy wrote: > > This was a question about the preprocessor, please

Re: [dev] Preprocessor

2019-04-23 Thread Peter Nagy
This was a question about the preprocessor, please take your sh (off-)topic to a different thread. That main, mostly the switch part, is huge! Having more than 3 levels of nesting of loops+conditionals (if, for, while, switch) is a code smell; it is hard to read, hard to reason about and easy t

Re: [dev] Preprocessor

2019-04-23 Thread Evan Gates
On Tue, Apr 23, 2019 at 12:42 PM Hadrien Lacour wrote: > That was just shitposting. I use `find` to avoid most of the UNIX braindamage > in this case. Which is good as long as you use -exec correctly. Or if you're going to use xargs make sure to use nul separated lists. Xargs without the nul opti

Re: [dev] Preprocessor

2019-04-23 Thread Hadrien Lacour
On Tue, Apr 23, 2019 at 09:30:14AM -0700, Evan Gates wrote: > On Tue, Apr 23, 2019 at 9:24 AM Hadrien Lacour > wrote: > > What if "$1" is empty? POSIX sh doesn't have the nullglob shop, you know. > > [ "$1" ] || exit # add a message if you want > [ -d "$1" ] || exit # if you want to check that the

Re: [dev] Preprocessor

2019-04-23 Thread Cág
Evan Gates wrote: Not sure about the preprocessor stuff, but this right here is terrible practice. Use a for loop and glob. Assuming that "$1" is a directory: for p in "$1"/*; do ... http://mywiki.wooledge.org/ParsingLs http://porkmail.org/era/unix/award.html -- caóc

Re: [dev] Preprocessor

2019-04-23 Thread Evan Gates
On Tue, Apr 23, 2019 at 9:24 AM Hadrien Lacour wrote: > What if "$1" is empty? POSIX sh doesn't have the nullglob shop, you know. [ "$1" ] || exit # add a message if you want [ -d "$1" ] || exit # if you want to check that the directory exists for p in "$1"/*; do [ -e "$p" ] || continue; ... # if

Re: [dev] Preprocessor

2019-04-23 Thread Hadrien Lacour
On Mon, Apr 22, 2019 at 01:35:02PM -0700, Evan Gates wrote: > On Mon, Apr 22, 2019 at 1:25 PM Adrian Grigore > wrote: > > > > ls -1 "$1" | while IFS= read -r p > > do > > Not sure about the preprocessor stuff, but this right here is terrible > practice. Use a for loop and glob. Assuming that "$1"

Re: [dev] Preprocessor

2019-04-22 Thread Evan Gates
On Mon, Apr 22, 2019 at 1:25 PM Adrian Grigore wrote: > > ls -1 "$1" | while IFS= read -r p > do Not sure about the preprocessor stuff, but this right here is terrible practice. Use a for loop and glob. Assuming that "$1" is a directory: for p in "$1"/*; do ... http://mywiki.wooledge.org/Parsin

[dev] Preprocessor

2019-04-22 Thread Adrian Grigore
Hi, I built a preprocessor. It allows embedding shell code in any type of files. Can you guys give some tips or a code review? The file format it accepts is the following: #!/home/adi/src/pp/pp #! ls -1 "$1" | while IFS= read -r p do #! $p