Scan from a comic where the hero throws an assortment of weapons. But instead, a backslash has been superimposed on each weapon and the hero shouts "Random backslashes go!!!!".

all 10 comments

sorted by: hot top controversial new old
[–] 19 points 1 year ago (4 children)

Regexes in bash commands are my nemesis.

  • source
  • hideshow 4 child comments
  • [–] 12 points 1 year ago (3 children)

    Regexes in bash commands are my nemesis.

  • source
  • parent
  • hideshow 3 child comments
  • [–] [S] 12 points 1 year ago* (2 children)

    This meme brought to you by me trying to pass a regex from Nix into a TOML, which is certainly not the worst backslash orgy I've seen, but tragic in its own right. Both Nix and TOML have a way to specify raw strings, which do not need escaping. But Nix uses a normal string when passing into TOML, so I do have to escape anyways. 🫠

    My regex also contains a double-quote, which was just guesswork as to how many backslashes I need there.

  • source
  • hideshow 2 child comments
  • [–] 3 points 1 year ago* (last edited 1 year ago) (1 child)

    But Nix uses a normal string when passing into TOML, so I do have to escape anyways

    What do you mean by that? You are always able to just use the '' strings instead of the " strings, they are just different syntax for the same underlying type. Or are you just using lib.generators.toINI without any arguments? Maybe try something like this:

    toTomlEscapeBackslashes = toINI {
      mkKeyValue = mkKeyValueDefault { mkValueString = x: lib.escape [ ''\'' ] (toString x); } "=";
    }
    

    This will escape the values, like this:

    nix-repl> :print toTomlEscapeBackslashes { my.regex = ''foo\nbar''; }
    [my]
    regex=foo\\nbar
    
  • source
  • parent
  • hideshow 1 child comment
  • [–] [S] 4 points 1 year ago

    I figured, I'd involuntarily sign up for counter suggestions by posting this. 😅

    Using lib.escape is a good idea, thanks.

    But yeah, basically I want to configure Alacritty and I'm using the respective home-manager module.
    Even more specifically, I want to pass stuff, including a regex, into the settings parameter, which more-or-less just takes the Nix expression that I shove in and then outputs it as TOML on disk.

    As for how I would've liked this to work:

    But the TOML is templated with "double-quotes", so I do need to escape the regex after all.

    I did just try to understand how the Alacritty module does the templating and found this gem:

    # TODO: why is this needed? Is there a better way to retain escape sequences?
    "substituteInPlace $out --replace-quiet '\\\\' '\\'"
    

    Source

    So, that doesn't fill me with a whole lot of confidence. 🙃

    But yeah, it's working now without me having to write a whole bunch of backslashes, so that's good enough in my book.

  • source
  • parent
  • [–] 10 points 1 year ago (1 child)

    Learning C: Random asterisks go

  • source
  • hideshow 1 child comment
  • 10 comments in c/programmer_humor@programming.dev view that post
    [–] 16 points 1 year ago (2 children)

    Aaaaaaaaaaaaaaaaaaa No!!!!! My data! Please stop doing that!

  • source
  • hideshow 2 child comments
  • [–] 12 points 1 year ago
    [[[[[["TCL/TK has \\\\\\\\\\"entered\\\\\\\\\\" the chat."]]]]]] 
    
  • source
  • [–] 6 points 1 year ago

    Oh you mean a pipiline defined in yaml, running in poweshell to execute a command in docker on windows?

  • source
  • [–] 3 points 1 year ago (2 children)

    I had to do this yesterday. First I tried ". Then \", finally \" worked. Which doesn't make sense. But I'm not looking for answers, I've got more Jira tickets this sprint.

  • source
  • hideshow 2 child comments
  • [–] 1 point 1 year ago

    Run a PowerShell script from batch, but call it using start-process as administrator, using a variable for the path and also pass parameters to the script.

  • source
  • [–] 1 point 1 year ago

    I added an expression support to my Automod for Lemmy which can have subexpressions as parameters etc., pretty cool to work with.

    Except every subexpression needs 2^n-1 slashes where n is the depth level. Fun times writing the expressions.

  • source