Skip Navigation

Posts
11
Comments
495
Joined
2 yr. ago

  • If the path to the dir is longer than $HOME, say, $HOME/Tools/modding/hd2-audio-modder/wwise/v123456789_idr_but_its_a_long_one/random file name with spaces, it makes more sense.

    I'll try using the braces syntax, if it does prevent word splitting I wasn't aware of it, though it's still slightly inconvenient (3 key inputs for each brace on my kb) and I'd probably still use quotes instead if I had to use Bash and had the file path in a variable for some reason.

    ... though at this point I'm probably overthinking it, atm I don't recall better examples of my distaste for Bash expansion shenanigans.


    Did some testing, here's what I found.Beware, it devolves into a rant against Bash and has little to do with the original topic - I just needed to scream into the void a little.

     zsh
        
    # Zsh
    function argn { echo $#; }
    
    var='spaced string'
    argn $var
    # Prints 1: makes sense, no word splitting here
    
    var=(array 'of strings')
    argn $var
    # Prints 2: makes sense, I'm using a 2-wide array where I would
    #           want 2 arguments (the second one happens to have
    #           a whitespace in it)
    
      

     
        
    # Bash
    function argn { echo $#; }
    
    var='spaced string'
    argn $var
    # Prints 2: non-array variable gets split in 2 with this simple reference;
    #           I hate it, but hey, it is what it is
    
    argn ${var}
    # Prints 2: no, braces do not prevent word splitting as I think you suggested
    
    var=(array 'of strings')
    argn $var
    # Prints 1: ... what?
    
    echo $var
    # Prints array: ... what?!?
    #               It implicitly takes the first element?
    #               At least it doesn't word-split said first element, right?
    
    var=('array of' strings)
    argn $var
    # Prints 2:
    
      


    Upon further investigation:

     
        
    # Bash
    mkdir /tmp/bashtest ; cd /tmp/bashtest
    touch 'file 1'
    touch 'file 2'
    
    stat file*
    # Prints the expected output of 'stat' called on both files;
    # no quotes or anything, globbing just expands into
    # 2 arguments without *word* splitting
    
    files=('file 1' 'file 2')
    stat $files
    # stat: cannot statx 'file'
    # stat: cannot statx '1'
    # WHY? WHY DOES GLOBBING ACT SENSIBLY WHEN ARRAYS DO NOT?
    
      

    I get that the Bash equivalent to Zsh's $array is ${array[@]}, but making $array behave like it does in Bash has no advantage whatsoever.... IS WHAT I WOULD SAY IF THAT WERE TRUE! YOU ALSO HAVE TO QUOTE "${array[@]}" BECAUSE WE LOVE QUOTES HERE AT BASH HQ!

     
        
    # ... continued from before
    stat "prefix ${files[@]}"
    # stat: cannot statx 'prefix file 1'
    # (regular 'stat' output for 'file 2')
    
      

    While this behavior doesn't make much sense to me, it also doesn't make sense for me to write that "prefix" within the quotes in the first place, right?YES. BECAUSE SPLITTING IS NOT WHAT YOU EXPECT WHEN YOU PUT STUFF IN QUOTES.

    Sorry, I'll stop.

  • o7, probably worth a shot

  • Expansion matters because using parameters without quotes automatically splits words, and IIRC a quoted array parameter can still be split into its members — as opposed to Zsh, where word splitting doesn't happen unprompted and quoted array parameters are flattened into a single string.

    Generally if I want to run $HOME/random executable with spaces.exe through Wine in a terminal I copy the path in Dolphin (CTRL+SHIFT+C, or CTRL+ALT+C idr) and paste it, within quotes if needed (the four extra key inputs are the annoying part).

    I find that much faster than manually typing find "$HOME" -name "random executable with spaces.exe" -type x -exec wine "{}" \;, or opening an editor to insert backslashes.

  • They're annoying to deal with when interactively using command-line shells, especially so when pasting unquoted and unescaped file paths, doubly especially so with Bash where parameter expansion makes no goddamn sense if you know at least one other programming language

  • It's not about the amount of swap space, it's a problem that happens when swapping happens for big chunks of data at a time.

    Windows aggressively swaps out things way before it's necessary, you can try increasing the system's "swappiness"; ~I'm writing this from my phone, but when I get to my PC I'll write out how to do it (unless somebody else does it before I do).~

    You can set it by writing vm.swappiness=60 in a file like /etc/sysctl.d/50-swappiness.conf.The value 60 is arbitrary, if you increase it the system will try to swap out things more aggressively; the name of the file is also partially arbitrary, but AFAIK, it has to begin with two digits — the system will read all the files inside /etc/sysctl.d in order, and the settings in higher-numbered files will be applied over lower ones.

    Officially, this is the explaination of the vm.swappiness parameter.You can read and write the value with your shell:

     bash
        
    #!/usr/bin/bash
    sysctl vm.swappiness  # shows you the current value
    sudo sysctl vm.swappiness=69  # sets the swappiness to 69 AND shows you the new value
    
      
  • A Wider and less Local LAN, if you will

  • Deleted

    Permanently Deleted

    Jump
  • No, I've tried twice to point out the simple concept of not being able to do something and its relation to [email protected] 's comment, I thought the second attempt may have been a bit too condescending but apparently it wasn't.

    I'm sorry but you're on your own.

  • Deleted

    Permanently Deleted

    Jump
  • "I can't afford to buy food, I'm hungry" "Have you tried buying food?"

    See the (non-philosophical) problem?

  • Deleted

    Permanently Deleted

    Jump
  • They said "I don't think you can banish feelings", you even quoted that, and you consequently suggest banishing feelings?

  • Your stepbrother's judgement depends on which Halo he plays, he still has a chance

  • The simulation absolutely runs on Windows, have you seen the random unwanted stuff that happens way too often in it?

  • Where's II Samuel 3:14?

  • Removed Deleted

    Permanently Deleted

    Jump
  • This AI generated meeting could have been an AI generated email

  • Understandable complaint, if it's anything like X3 or Avorion

  • Makes more sense ig

  • I thought so too, but IME it's fine

  • They cared to optimize for hard disks? Odd but respectable

  • Thanks for the link, it addresses both of the doubts I've expressed in the post; perhaps at some point I'll play a game with DS and see how well it carries over to Linux despite the lack of a similar API, I'll probably stick to the small RAID0 fs I already have and use it for X4 or something.