explain_realpath_or_die(3)

πŸ“¦
version 1.4.D001 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute

πŸ’– explain_realpath_or_die β€” the libexplain glow-up πŸ’–

okay bestie, so you know explain_realpath_or_die(3)? that's the manual page we're living in right now, section 3, from the Library Functions Manual. it's giving "canonical pathname, but make it loud when things go wrong." let's get into it ✨


🌸 NAME 🌸

explain_realpath_or_die β€” return canonical pathname and report errors

like. that's it. that's the whole vibe. you get your canonical pathname, and if anything goes sideways, it tells you about it. no silent suffering. we don't do that here πŸ’…


✨ SYNOPSIS ✨

#include <libexplain/realpath.h>
char *explain_realpath_or_die(const char *pathname, char
*resolved_pathname);
char *explain_realpath_on_error(const char *pathname, char
*resolved_pathname);

two functions, both icons, both included via <libexplain/realpath.h>. 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

so explain_realpath_or_die is the function you call when you want to call the realpath(3) system call, but you want drama on failure. if it fails, an explanation gets printed to stderr β€” and that explanation comes from the explain_realpath(3) function β€” and then the whole process terminates by calling exit(EXIT_FAILURE). like, it does not come back. it's gone. it said what it said and it left the chat 😭

meanwhile explain_realpath_on_error is the chiller sibling. it also calls the realpath(3) system call, and on failure it also prints an explanation to stderr obtained from the explain_realpath(3) function β€” but then it still returns to the caller. so you get the tea, and you get to keep going. best of both worlds fr fr.

now the arguments, because we respect the parameters in this house:

  • pathname β€” the pathname, exactly as to be passed to the realpath(3) system call. no edits, no seasoning, exactly as-is. πŸ‘‘
  • resolved_pathname β€” the resolved_pathname, exactly as to be passed to the realpath(3) system call. same energy, same rule. 🌈

πŸ’œ RETURN VALUE πŸ’œ

  • explain_realpath_or_die only returns on success β€” check realpath(3) for more info on what success even means here. on failure? it prints an explanation and exits. it does not return. periodt. πŸ’€
  • explain_realpath_on_error always returns the value returned by the wrapped realpath(3) system call. every time. no surprises. πŸŽ€

πŸ“ EXAMPLE πŸ“

the explain_realpath_or_die function is intended to be used in a fashion similar to the following example:

char *result = explain_realpath_or_die(pathname, resolved_pathname);

that's the whole thing. short, sweet, canonically correct. ate. πŸ”₯


🧚 SEE ALSO 🧚

iykyk, go read those next, they're all connected bestie 🌸


this whole thing is libexplain version 1.4, and the copyright belongs to Copyright (C) 2011 Peter Miller. respect the author, always πŸ’–


and that's the page!! tysm for reading, mwah 🫢 β€” signed, sealed, delivered, explain_realpath_or_die(3), Library Functions Manual, libexplain 1.4, 2011, Peter Miller's copyright, and this footer section is officially closed. slay πŸ’…βœ¨

πŸ“¦ where this page comes from