Hacker Newsnew | past | comments | ask | show | jobs | submit | oguz-ismail2's commentslogin

Nit pick, but

>FILE* f = fopen(path, "rb");

>...

>if (fseek(f, 0, SEEK_END) != 0) return option_charp_none();

>long len = ftell(f);

does ISO C guarantee this'll work these days? How come there's no fread+realloc fallback?


Good catch! You’re right, ftell + fseek isn’t guaranteed to work for all files in ISO C, especially very large or non-seekable ones. In practice, for typical binary files it works fine, but I’ll add a note in the docs. I will consider a fallback using fread + realloc for full portability.


It's a question of scale. Neither crime is less serious but far more children are groomed and abused over Discord than flown in via some super rich sicko's private jet for a 'costume party'.


Making everyone "teens by default" fixes none of that, though. Roblox spaces aren't exactly 18+


Since when `{...}' syntax is a glob pattern? What does `{a,b}/c' produce when there is no directory named `a'?


Since glibc (better to say csh) implemented it. https://man7.org/linux/man-pages/man3/glob.3.html search for GLOB_BRACE


Globbing is a matching library. It just means match a/c or b/c if they exist. You should get an iterator of somewhere between zero and two elements.


would it not just produce 'b/c'? assuming 'b/c' is an existent file path

what else could you justify it doing?


The behavior of bash would be to produce "a/c" and "b/c", even if both files don't exist


> The behavior of bash would be to produce "a/c" and "b/c", even if both files don't exist

In bash patterns like {a,b} aren't glob-expansion expansions, they're string operations, and those resolve before glob expansions.

You can confirm this with: ls /{nope,tmp}


zsh too


What sibling comment says. Bash does suppress nonexistent products when the pattern includes a glob metacharacter and `shopt -s nullglob' is in effect, but I didn't see a flag or anything to achieve that in the project README.


Title says Unix, renameat2 is Linux-only.


>Title says Unix,

You're misinterpreting the title. The author didn't intend "Unix" to literally mean only the official AT&T/TheOpenGroup UNIX® System to the exclusion of Linux.

The first sentence of "UNIX-like" makes that clear : >This is a catalog of things UNIX-like/POSIX-compliant operating systems can do atomically,

Further down, he then mentions some Linux specifics : >fcntl(fd, F_GETLK, &lock), fcntl(fd, F_SETLK, &lock), and fcntl(fd, F_SETLKW, &lock) . [...] There is a “mandatory locking” mode but Linux’s implementation is unreliable as it’s subject to a race condition.


Bit rot alert: Linux doesn't even have mandatory file locks these days.

Linux-specific open file description locks could be brought up in a modern version of TFA though.


But I also don't think the auther meant Things you can do in Linux but not Unix


>But I also don't think the auther meant Things you can do in Linux but not Unix

I wasn't claiming that. I just thought the ggp had a useful comment about renameat2() which led to gp's "correction" which wasn't 100% accurate.

IBM z/OS UNIX also has renameat2(). It doesn't have the Linux specific flag RENAME_EXCHANGE.

https://www.ibm.com/docs/en/zos/3.1.0?topic=functions-rename...


In recent versions, z/OS has been copying lots of Linux-specific APIs (e.g. unshare [0]) in order to support the z/OS port of Kubernetes.

If Kubernetes starts using renameat2(RENAME_EXCHANGE), they could very plausibly add it.

[0] https://www.ibm.com/docs/en/zos/3.2.0?topic=csd-unshare-bpx1...


pedantic but z/OS isn't a unix, it can just pretend to be one enough for the open group to call it one. IBM has a unix still, AIX.


They aren’t misinterpreting the title, the title is incorrect.


>, the title is incorrect.

Differing philosophies of how to interpret titles. Prescriptive vs Descriptive language.[0]

There can be different usages of the word "Unix":

#1: Unix is a UNIX(tm) System V descendent. More emphasis that the kernel needs to be UNIX. In this strict definition, you get the common reminder that "Linux is not a Unix!"

#2: "Unix" as a loose generic term for a family of o/s that looks/feels like Unix. This perspective includes using an o/s that has userland Unix utilities like cat/grep/awk. Sometimes deliberately styled as asterisk "*nix" or a suffix-qualifier "Unix-like" but often just written as a naked "Unix".

A Prescriptivist says the author's title is "incorrect". On the other hand, a Descriptivist looks at the whole content of the article -- notices the text has a lot of Linux specific info such as fcntl(,F_GETLEASE/F_SETLEASE), and every hyperlink to a man page url points to https://linux.die.net/man/ , etc -- and thus determines that the author is using "Unix"(#2) in the looser way that can include some Linux idiosyncrasies.

"Unix" instead of "*nix" as a generic term for Linux is not uncommon. Another example article where the authors use the so-called incorrect "Unix" in the title even though it's mostly discussing Linux CUPS instead of Solaris : https://www.evilsocket.net/2024/09/26/Attacking-UNIX-systems...

[0] https://en.wikipedia.org/wiki/Linguistic_prescription


Sounds like the key term then is probably this:

> POSIX-compliant

Which, FWIW, doesn't mean Linux. AFAIK there is no Linux distro that's fully compliant, even before you worry about the specifics of whether it's certified as compliant.


>POSIX-compliant Which, FWIW, doesn't mean Linux. AFAIK there is no Linux distro that's fully compliant

I read author's use of "POSIX-compliant" as a loose and fuzzy family category rather than an exhaustive and authoritative reference on 100% strict compliance. Therefore, the author mentioning non-100%-compliant Linux is ok.

There seems to be 2 different expectations and interpretations of what the article is about.

- (1) article is attempting to be a strict intersection of all Unix-like systems that conform to official UNIX POSIX API. I didn't think this was a reasonable interpretation since we can't be sure the author actually verified/tested other POSIX-like systems such as FreeBSD, HP-UX, IBM AIX, etc.

- (2) article is a looser union of operating systems and can also include idiosyncracies of certain systems like Linux that the author is familiar with that don't apply to all other UNIX systems. I think some readers don't realize that all the author's citations to man pages point to Linux specific urls at : https://linux.die.net/man/

The ggp's (amstan) additional comment about renameat2(,,,,RENAME_EXCHANGE) is useful info and is consistent with interpretation (2).

If the author really didn't want Linux to be lumped in with "POSIX-like", it seems he would avoid linux.die.net and instead point to something more of a UNIX standard such as: https://unix.org/apis.html

[0] Intersection vs Union: https://en.wikipedia.org/wiki/Set_(mathematics)#Intersection


AFAIK you don't even want to be POSIX-compliant unless having a sticker means more to you than being reasonable. Most projects knowingly steer away from compliance (and certifying compliance is probably also expensive)


The slash is read as "OR" in this case.

As in: Unix-like OR POSIX-compliant

In that light, it's probably fine to not nitpick over certifications here.


EulerOS was certified UNIX some years ago.


Huh, TIL. Thanks.


Except POSIX doesn't specify some of them as happening atomically.

Many people write UNIX/POSIX without ever reading what it says.


> The Ashley Book of Knots is fantastic.

Yup. Referring to knots by their ABoK numbers is also more practical than by their wildly varying names.


fish and zsh real silent since this dropped


> How does that work, with syscalls being unable to be called except from the system’s libc?

OpenBSD allows system calls being made from shared libraries whose names start with `libc.so.' and all static binaries, as long as they include an `openbsd.syscalls' section listing call sites.


Can't you just have one syscall(2) to rule them all? https://man7.org/linux/man-pages/man2/syscall.2.html


You can. There is a thread-unsafe implementation here <https://gist.github.com/oguz-ismail/72e34550af13e3841ed58e29...>. But the listing needs to be per system call number, so this one only supports system calls 1 (_exit) and 4 (write). It should be fairly easy to automatically generate the complete list but I didn't try it.


> Rustrover (intellij) can certainly produce coverage reports.

See <https://sqlite.org/testing.html#statement_versus_branch_cove...>. Does Rustrover produce branch coverage reports?


Yes! A quick google brings up cargo-llvm-cov[1], which is a rust wrapper around llvm source code coverage. It has an unstable --branch command for branch coverage, but branch coverage currently has some language level limitations[2].

[1] https://github.com/taiki-e/cargo-llvm-cov

[2] https://github.com/rust-lang/rust/issues/124118


*horses


Does this spawn a new shell for every instance of $`...`?


Yep each one is a fresh session. Are you asking because you'd like a persistent one?


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: