• 1 Post
  • 21 Comments
Joined 19 days ago
cake
Cake day: March 13th, 2025

help-circle



  • mina86@lemmy.wtfOPtoLinux@lemmy.mlIs Ctrl+D really like Enter?
    link
    fedilink
    English
    arrow-up
    0
    ·
    3 days ago

    Yeah, it’s a bit philosophical.

    • In graphical applications, Ctrl+M, Ctrl+J and Return/Enter are all different things.
    • In a terminal in raw mode, Ctrl+M and Return/Enter are the same thing but Ctrl+J is something different. You can for example run bind -x '"\C-j":"echo a"' and Ctrl+J will do something different.
    • In a terminal in canonical mode, they are all the same thing. There probably are some stty options which can change that though.




  • You want readlink -f rather than ls -l. ++OK, actually not exactly. readlink won’t print path to the symlink so it’s not as straightforward.++

    Also, you want + in find ... -exec ... + rather than ;.

    At this point I feel committed to making readlink work. ;) Here’s the script you want:

    #!/bin/sh
    
    want=$1
    shift
    readlink -f -- "$@" | while read got; do
    	if [ "$got" = "$want" ]; then
    		echo "$1"
    	fi
    	shift
    done
    

    and execute it as:

    find ~ -type l -exec /bin/sh /path/to/the/script /path/to/target/dir {} +
    







  • mina86@lemmy.wtftoLinux@lemmy.ml*Permanently Deleted*
    link
    fedilink
    arrow-up
    0
    ·
    edit-2
    11 days ago

    If you have an SVG image you can either embed it directly on the website, or link it using img tag. Whatever the case, there’s no need to export it to PNG.

    And yes, that will likely result in a smaller website and furthermore images which can scale smoothly.


  • mina86@lemmy.wtftoLinux@lemmy.ml*Permanently Deleted*
    link
    fedilink
    English
    arrow-up
    0
    ·
    11 days ago

    Another interesting part is that HTML5 supports embedding SVG. That is, you can put SVG code directly in your HTML5 document and it’s going to render correctly. You can also style it through your website’s CSS file and manipulate the elements via JavaScript.

    Though as others pointed out, it’s technically not HTML but XML.




  • Sure, though I advice against it. The following C program can do that:

    #include <stdio.h>
    #include <stdlib.h>
    #include <unistd.h>
    
    int main(int argc, char **argv) {
    	if (argc < 2) {
    		fprintf(stderr, "usage: %s <command> <args>...", argv[0]);
    		return EXIT_FAILURE;
    	}
    
    	printf("Executing");
    	for (int i = 1; i < argc; ++i) {
    		printf(" %s", argv[i]);
    	}
    	puts("\nPress ^C to abort.");
    	sleep(5);
    
    	if (setuid(0)) {
    		perror("setuid");
    		return EXIT_FAILURE;
    	}
    
    	execvp(argv[1], argv + 1);
    	perror(argv[1]);
    	return EXIT_FAILURE;
    }
    

    As seen in:

    $ gcc -O2 -o delay-su delay-su.c
    $ sudo chown root:sudo delay-su
    $ sudo chmod 4750 delay-su
    $ ./delay-su id
    $ id -u
    1000
    $ ./delay-su id -u
    Executing id -u
    ^C to abort
    0
    

    This will allow anyone in group sudo to execute any command as root. You may change the group to something else to control who exactly can run the program (you cannot change the user of the program).

    If there’s some specific command you want to run, it’s better to hard-code it or configure sudo to allow execution of that command without password.


  • It’s not. You keep insisting that ^D doesn’t send EOF and yet:

    $ stty -a | grep eof
    intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
    $ man stty |grep -A1 eof |head -n2
           eof CHAR
                  CHAR will send an end of file (terminate the input)
    

    ^D is the EOF character. The thing is that in C every line of a text file must be terminated by a new-line. And so, when you end a file with ^D without a return, you get funky results.

    If you think ^D is like Enter, start a shell and without running a command press ^D.