« first day (3350 days earlier)      last day (1587 days later) » 

6:15 AM
@Isaac The bit I'm not clear on is that the Lua code is calling a function it's not defined. Does it include a header file, and I'm missing it? And does it need to link to some library, or not?
 
 
2 hours later…
8:33 AM
Does anyone understand what is going on with:
4
A: LuaLaTeX: Extract basename from path

Henri MenkeYou can easily get the basename in LuaTeX using the FFI and a platform-dependent function. On POSIX-based systems you can use the basename() function. Because it uses the FFI you have to enable --shell-escape. In tex.sprint I use the first argument -2 to switch to verbatim catcodes, in case th...

I think the code is declaring the function, but doesn't it need to link to something? Which library does this "libgen.h" correspond to, anyway?
It says it's a POSIX thing, which means it should be available on Linux.
 
9:31 AM
It’s part of the C library on Linux, so there’s no extra library to link to in the vast majority of cases.
 
 
1 hour later…
11:02 AM
I'm teaching Unix shell scripting tomorrow, to a bunch of bioinformaticians.
Haven't taught in 20 years.
 
Wow I hope it goes well!
Is your first lesson “learn Python”?
:-P
 
@StephenKitt Not really. That would make it easier though, as I could just say "I don't know anything, look it up online".
 
 
3 hours later…
1:45 PM
@Kusalananda I'm sure it'll be great!
1. chsh -s /bin/zsh
2. profit
 
@JeffSchaller I'm doing the third day out of three. "Shell scripting" is the topic of the day. I'll show sh syntax, variabls, basic control structures, and some bash features (arrays, and glob/regex matching with == and =~).
Sadly, going into zsh will probably be a bit much.
 
2:02 PM
@Kusalananda oh I completely agree; it was a tongue-in-cheek suggestion. You'll get them going in a sane direction, I'm sure! Future UNIX admins thank you!
 
@JeffSchaller In the answers to one of the exercises, I do show a zsh one-liner variant of a 10 line bash script though.
 
@Kusalananda ahhhh, I like it!
 
2:47 PM
@StephenKitt I see. So as long as the function signature is correctly stated, it should work?
 
@FaheemMitha yes.
 
@StephenKitt Ok, thank you. So the basename function in the C library would have to confirm to pubs.opengroup.org/onlinepubs/9699919799/functions/….
Though I'm not sure if the libc people consider themselves bound to follow POSIX or not.
 
@Kusalananda bioinformaticians.? I'll be so bold as to give some (useful?) tips: Make sure to clearly explain the UNIX idea of pipes cmd1 | cmd2. Mention the concept of "do one thing, do it well". Give them a list of basic utilities, do include (some examples of) sed, and awk. Mention the idea of using Perl (or even Python) when the problem is complex enough. Mention that "when the problem becomes complex to solve in one language maybe you are using the wrong language to solve it".
 
@Isaac All good, and most of that is covered by others other than me. We're not covering Perl and awk though as we have separate courses for that.
I'm just covering the shell scripting aspects.
 
2:56 PM
@StephenKitt I see. It's good that it is clearly stated. Thank you.
 
@Kusalananda Then, maybe, tell them: Understand that the shell scripting language is an organic concept that has been growing for more than 50 years (and keeps changing). There are some aspects of it that are not logic, they were not designed in but inserted into an already existing framework of ideas. Don't expect solutions to be easy/simple in many cases. or perhaps that may scare them more than guide them, I am not all that clear about this.
 
My impression is that regexes are closely associated with the early history of Unix. And this seems to be at least partly confirmed by en.wikipedia.org/wiki/Regular_expression.
 
3:12 PM
15
Q: What was the first language with regexes?

LaurelAccording to Wikipedia, Regular Expressions (AKA regexes) have only been around since 1956: Regular expressions originated in 1956, when mathematician Stephen Cole Kleene described regular languages... Other early implementations of pattern matching include the SNOBOL language, which did not ...

 
Huh. So regexes are a regression of sorts?
 
@FaheemMitha Regexes are the natural expansion of pattern matching (globing or how to make a * a list of files). Globing has been in the shell for a very long time, it was then formally analyzed and was converted to a "regular language" thus the name "regular expressions".
 
@Isaac no, globbing came after regexes
 
@Isaac You should look at the link that Stephen posted. It's got more information about the early history than the WP page does.
In particular, there were languages with integrated pattern matching abilities. Which isn't common these days. In fact, I can't think of one. Even Common Lisp doesn't.
 
@FaheemMitha based on the comparison with SNOBOL? But SNOBOL came out after regexes were devised...
@FaheemMitha AWK?
 
3:21 PM
@StephenKitt Around the same time, it sounds like. Ok, maybe not a regression, then.
@StephenKitt Um. Is that a full fledged language. I don't really know it.
 
@FaheemMitha regexes, 1956, SNOBOL, 1962 ;-)
@FaheemMitha yes, it is.
 
@StephenKitt Something called COMIT, 1957?
 
(Although the answer depends on what you mean by “fully-fledged”!)
 
@StephenKitt Indeed. Variables, loops, functions, scoping...
 
@FaheemMitha SNOBOL patterns can represent more than regexes, but I don’t think COMIT patterns can...
 
3:23 PM
@StephenKitt Oh
 
@FaheemMitha yes, AWK has all that.
 
@StephenKitt Ok.
And types as well? Integers/floats/doubles, strings, booleans?
 
@Isaac Note that these are people that have difficulties in finding the ~ and $ characters on their keyboards.
(on account of having localized keyboards)
 
@FaheemMitha strings, numbers, and strnums, dynamically-typed
 
@StephenKitt Ah, strnums. A hybrid?
 
3:36 PM
@FaheemMitha yes, values which can be interpreted as strings or numbers depending on the context
 
Hmm.
 
@StephenKitt Yes, the math **concept** of "regular expressions" is [from 1951 (Klenee)](https://en.wikipedia.org/wiki/Regular_expression#History) but note that they were called "regular events". However the practical aplication took some years to spread to the computer world.

[With reference](https://en.wikipedia.org/wiki/Glob_(programming)) *The glob command, short for global, originates in the earliest versions of Bell Labs' Unix.*

[Then](https://en.wikipedia.org/wiki/Glob_(programming)#Unix-like) *Extended Globbing (extglob): allows other pattern matching operators to be used to match
@StephenKitt So, glob was extended to (kind of) match regular expressions.
 
@Isaac seriously, no. Thompson implemented regexes in QED in 1968, before starting work on Unix.
2
 
@StephenKitt Then why do we have globs (a run down regular concept) instead ot the Kleene star from the first Unix version?
 
@Isaac you’d have to ask Thompson. But regexes existed before globs did, so they weren’t an extension of globs.
 
4:23 PM
@StephenKitt What is the mood wrt the British General Election tomorrow? And are you voting?
 
4:39 PM
@FaheemMitha I’m not sure what the mood is, I haven’t been paying attention to the media today... I can’t vote unfortunately, I’ve been out of the country for too long.
 
4:56 PM
@StephenKitt Oh. Sorry to hear that.
There are residence requirements?
 
They don't want just any resident of Saint Kitts deciding the fate of England
 
Well, the CAB bill passed in the Rajya Sabha. That's not good.
 
@FaheemMitha right, to register on the electoral rolls you have to live in the UK; once that’s done, you can renew your electoral registrations for fifteen years after leaving the country (if you remember to do it once a year), but I’ve lived outside the UK for more that fifteen years
 
@StephenKitt More than 15 years? That's a long time.
Anyway, we're mostly getting news here. Let's hope for a hung parliament, at least.
 
@FaheemMitha TBH I don’t trust the lib dems if it comes to that
but yes, anything but a tory majority
 
5:10 PM
@StephenKitt Don't trust them in what sense?
 
@FaheemMitha not to form a coalition with the tories
 
@StephenKitt Do you really think they would do that? They've clearly split with them on Brexit?
 
@FaheemMitha one would get that impression, but given some of the things they’ve been saying recently, I wouldn’t put it past them
 
@StephenKitt Oh. One more reason to worry.
 
5:25 PM
Sigh. I wouldn't really put anything past any of them. A plague on all their parties.
The bloody Greens put an election flyer into my mailbox. Printed on non-recycled, laminated paper. Seriously, Greens? You don't see the irony?
"Yay, we want to protect the environment, but we'll throw a few tons of paper around town just to get started"
 
Next they'll be using unquoted variable expansions!
 
The horror!
But seriously, a green party littering is just absurd. And non-recycled laminated paper!?
 
Yes. I find it rather telling that the only sensible parties seem to be the separationist parties outside of England (the SNP, Plaid Cymru, and amazingly enough, Sinn Fein)...
The SNP wins for having the only obviously-pronounced name ;-).
 
Exactly. When that type are the ones who are most reasonable, you know the world has gone mad.
 
The world indeed.
I’m absolutely gob-smacked that there is no party in France capable of representing the large popular movements of the last year (yellow jackets and the current anti-retirement-reform protests).
Well, not gob-smacked, it’s not surprising, but extremely disappointed.
Basically political parties no longer represent the people.
 
5:33 PM
@StephenKitt Yes, Thompson implemented regexes in QED in 1968. But what I have been saying is: That regexes were implemented after globs in the shell. The Thomson shell had globs man.cat-v.org/unix-1st/1/sh but not regexes.
 
2 hours ago, by Isaac
@FaheemMitha Regexes are the natural expansion of pattern matching (globing or how to make a * a list of files). Globing has been in the shell for a very long time, it was then formally analyzed and was converted to a "regular language" thus the name "regular expressions".
@Isaac what I’m saying is that the second sentence in your quote above isn’t accurate.
2
Also, the Unix shell never implemented regexes AFAIK ;-).
 
5:54 PM
@StephenKitt Shells nowadays have PCREs. Globs --> Regexes. Natural evolution seems inevitable?
 
@Isaac A couple of shells have them. Everyone seems to be misusing them. Globs are still more convenient for doing filename globbing.
 
@Kusalananda Oh sure, one character (*) is easier to type (and sometimes to grasp) than two characters (.*). Than is the main difference and rub between globs and regexes. If some other character were chosen (like % or &) to mean "any character in any count" in both globs and regexes the life of all shell users would be easier/simpler nowadays.
 
6:18 PM
@StephenKitt The Labor Party strikes me as relatively reasonable. Better than Blair, at any rate. At least they seem to be thinking in progressive terms.
 
@StephenKitt an interesting article on regex and theory: swtch.com/~rsc/regexp/regexp1.html
 
 
1 hour later…
7:44 PM
@Isaac Also, regular expressions are not anchored by default, while globs are. So to match a filename that starts with c and ends with d, you would need ^c.*d$ with a regular expression, and c*d with a glob. Regular expressions are more powerful, no doubt about that, but their power lies elsewhere than in things a user might want to do at their command prompt.
 

« first day (3350 days earlier)      last day (1587 days later) »