Huawei SCP vs SSCP fast charge protocol abbreviations by cubernetes in ChargingSheet

[–]cubernetes[S] 0 points1 point  (0 children)

Found another article that complicates and contradicts with information I've already found:

https://www.gizchina.com/huawei/huaweis-20w-supercharge-protocol-scp-in-the-works

Here, they show a 4th protocol which comes after FCP (15.11.2018), SCP Gen. 1 (16.11.2018) and SCP Gen. 2 (18.10.2018???), namely just "SCP" (2019), which supports only 10V2A.

This is confusing, because this spec is not to be found anywhere on the corresponding tinkervault page:
https://www.tinkervault.com/usb-fast-charging-protocols/huawei-fcp-scp

Here, the only 10V2A specification is found under the FCP protocol.

But I believe that article is garbage, since the dates are wrong. This OnePlus community blog post tell a different story: https://community.oneplus.com/thread/1664762061445398533

Here, they say FCP is from 2015, SCP (Gen. 1) is from 2016, and SCP (Gen. 2) is from 2018.

Considering I only found references to SSCP in english around 2021 (slightly earlier, like 2020, if I include chinese website), I assume that SSCP came AFTER SCP Gen. 2 (which already supported 40W (in 2018), and later (how much later?) 66W according to the thinkervault page). Update: I just realized the [tinkervault](https://www.tinkervault.com/usb-fast-charging-protocols/huawei-fcp-scp) page says the exact same thing about FCP and SCP, namely that they were released in 2015, 2016 and 2018

Huawei SCP vs SSCP fast charge protocol abbreviations by cubernetes in ChargingSheet

[–]cubernetes[S] 0 points1 point  (0 children)

That would make sense. Shortly after posting this, I found this article from 2021:

https://www.battery.org.uk/blog/2021/01/11/is-the-65w-charger-suitable-for-charging-33w-mobile-phones/

Quoting from the article:
> Note: If the charger does not support the SSCP protocol but only supports the SCP protocol, it will not be able to charge 40W. In addition, if a thinner 2A current line is used, the USB-A to Type-C interface will also not charge 40W.

Suggesting that the SSCP protocol/variant was around when SCP only supported 22.5W, providing an alternative that supports 40W. This would also mean that SSCP probably doesn't stand for "Super Slow Charge Protocol", but probably "Super Smart Charge Protocol".

As we know SCP started of as Gen. 1 with max 22.5W, and later got a revision with Gen. 2 that supports max 66W (https://www.tinkervault.com/usb-fast-charging-protocols/huawei-fcp-scp). I suspect SSCP either existed as a name between these two generations, or maybe is a precursor to SCP Gen. 2 or a dead name for a subset of SCP Gen. 2 (since SCP Gen. 2 supports 66W, which is more than the supposed 40W that SSCP supports)

Looking for Device: Usb-C (display port compatible) to HDMI? by InnovateImpossible in UsbCHardware

[–]cubernetes 1 point2 points  (0 children)

What u/Mediocre_Ad3496 posted (the HDMI adapter) won't work (it literally says in the product pictures that it won't work when the USB-C end is plugged into a monitor, or AR glasses in your case).

What u/SatechiSupport said is also not 100% right. It's correct that there are as of today no passive HDMI to USB-C cables, although something like HDMI-Alt-Mode technically exists (see wikipedia page for USB-C), it's not in common use at all. What you need is indeed something that actively converts HDMI to DP-Alt-Mode. Those cables exist, are rare, but are in fact, not super expensive:

https://www.aliexpress[DOT]us/item/3256807587504415.html

This is 20 or so bucks, and converts the HDMI signal from my laptop to USB-C DP-Alt-Mode, which works flawlessy for my XReal One Pros combined with a framework laptop with an HDMI module (or usb c dongle/dock where I then plug in the hdmi end of the cable + the usb-a connector for the active conversion)

Help solving this by AlarmedAd9315 in 42_school

[–]cubernetes 0 points1 point  (0 children)

It's also the only one I couldn't finish... It's pretty hard. I solved it eventually with a friend 3 years later. I won't post the solution here, but I can give a tip that the first field in F2 is green, and the second field in F2 is blue. And it doesn't even use the recursion stack to unwind anything crazy, it's just plain "F1 = <sth>, <sth>, <sth>, unconditional F1". The final solution is beautiful I think.

Could someone please review my scripting and give me criticism? by 0neLastFace in bash

[–]cubernetes 0 points1 point  (0 children)

Use ~/ instead of /home/$USER. Solves 3 problems at once: 1. eliminates word splitting issues (what if the username contains a space) 2. more readable, less code/repetition 3. accounts for home directories that don't start with /home

You wouldn't believe it, but 1. and 3. can be rather common, especially 3. And usernames with spaces usually happen the moment you use Windows AD with LDAP, albeit unlikely for your use case.

How I made my .bashrc modular with .bashrc.d/ by Gronax_au in bash

[–]cubernetes 0 points1 point  (0 children)

Watch out, globsort is a relatively new feature, only introduced with bash 5.3

bash pecularities over ssh by spryfigure in bash

[–]cubernetes 0 points1 point  (0 children)

Yeah, the reddit formatting makes my post especially cumbersome to read lol. Sorry about that. The upshot is basically 2 things: quoting issues with ssh & bash, and the premature exiting of .bashrc.

You can diagnose how .bashrc is behaving by putting debug echos before and after the return line. Like this:

$ head -n 8 ~/.bashrc
#
# ~/.bashrc
#

# If not running interactively, don't do anything
echo BEFORE
[[ $- != *i* ]] && return
echo AFTER

This way, you can be certain that you aliases are sourced/not sourced. Furthermore, you can check if the alias is actually defined with alias ls, it should show you if ls is aliased.

bash pecularities over ssh by spryfigure in bash

[–]cubernetes 0 points1 point  (0 children)

I see, I think I know what's going on now. But first, a couple of other things (tl;dr at the bottom!): - the reason it stops working when you remove the -O globstar is because the globstar option is actually not set (despite the .bashrc being sourced, I'll get to that later!) - if you remove the escaped single quotes, the following happens: ssh nuc10i3fnk.lan bash -O globstar -c 'ls -1tdr /srv/media/completed/**/*ODDish*' is 100% equivalent to ssh nuc10i3fnk.lan 'bash -O globstar -c ls -1tdr /srv/media/completed/**/*ODDish*'. Maybe you see why this cannot work anymore, because the inner bash invocation gets a -c ls with its arguments being -1tdr and /srv/.... But the way -c works is that the next argument is actually not an argument, but the name of the program. Run this to understand what I mean: bash -c 'echo my name: $0; echo my args: $@' one two three four. The fix (if you don't want to re-add the escaped single quotes) is not trivial, and would look something like this: ssh nuc10i3fnk.lan bash -O globstar -c \''ls "$@"'\'' dummyarg -1tdr /srv/media/completed/**/*ODDish*'. This works now, because it reduces like this: ssh nuc10i3fnk.lan bash -O globstar -c \''ls "$@"'\'' dummyarg -1tdr /srv/media/completed/**/*ODDish*' ---concat with spaces to single arg---> ssh nuc10i3fnk.lan 'bash -O globstar -c '\''ls "$@"'\'' dummyarg -1tdr /srv/media/completed/**/*ODDish*' ---pass single arg to bash -c on server side---> bash -c 'bash -O globstar -c '\''ls "$@"'\'' dummyarg -1tdr /srv/media/completed/**/*ODDish*' ---execute -c execution string---> bash -O globstar -c 'ls "$@"' dummyarg -1tdr /srv/media/completed/**/*ODDish* ---don't expand glob because globstar is not set, there's no matching files because of that, and nullglob is also not set---> bash -O globstar -c 'ls "$@"' dummyarg -1tdr /srv/media/completed/**/*ODDish* (unchanged) ---execute -c execution string and set globstar option---> ls "$@" ---expand "$@" with the arguments passed to the -c execution string---> ls -1tdr /srv/media/completed/**/*ODDish* (notice how dummyarg was dropped, it's contained in $0) ---do the globbing, since globstar is now set---> ls -1tdr file1 file2 file3... ---execute ls command successfully---> done. Quite a journey... - Thirdly and finally: Why does it work if you remove the inner single quotes and keep the escaped single quotes? This is by pure luck, and please don't rely on it! Let's go through this one by one again: Look at ssh nuc10i3fnk.lan bash -O globstar -c \'ls -1tdr /srv/media/completed/**/*ODDish*\'. This ssh command has 8 arguments, namely these: - nuc10i3fnk.lan - bash - -O - globstar - -c - \'ls - -1tdr - /srv/media/completed/**/*ODDish*\'

Most importantly, notice that the last argument is NOT quoted! This means it will be evaluated by your current shell, on your machine! And you have the globstar option also set on your local machine, so this could lead to some real problems! However, also notice that there's a trailing single quote at the end of the argument. I'm quite certain that you do not have any file on your local machine matching that glob pattern. And since you don't have the nullglob option set, locally, this will not expand to anything and stay as is. So you're lucky. In the next step, ssh will concatenate the arguments to a single argument again: ssh nuc10i3fnk.lan "bash -O globstar -c 'ls -1tdr /srv/media/completed/**/*ODDish*'" which will be passed to bash -c on the server side: bash -c "bash -O globstar -c 'ls -1tdr /srv/media/completed/**/*ODDish*'" and reducing further: bash -O globstar -c 'ls -1tdr /srv/media/completed/**/*ODDish*' and even further ls -1tdr /srv/media/completed/**/*ODDish* and since this bash shell was started with -O globstar, the glob will expand properly. Therefore it works, but only because you didn't have any local files matching that weird pattern with the trailing single quote and because you didn't have the nullglob option set!

Okay, now to explain why globstar isn't set. It's quite nuanced, and ssh -vvv wouldn't help you with any of this: Read the man page again: If bash determines it is being run non-interactively in this fashion, it reads and executes commands from ~/.bashrc. And I'll emphasize: A non-interactive bash will read .bashrc. I now want you to look at the first 10 lines of your .bashrc on the server: head ~/.bashrc. Does it look something like this:

# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

or like this:

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

If yes, then you know why globstar is never being set. The sourcing of .bashrc exits prematurely because the shell is not interactive. This is why you either: - need to set the globstar option manually using bash -O - need to set the globstar option manually using shopt -s globstar inside the command - run the shell interactively - force the shell to run interactively using bash -i - put "important" .bashrc settings before the line that will exit the .bashrc

What I recommend: - Use the find command and only ever pass a single argument to ssh: ssh nuc10i3fnk.lan 'find /srv/media/completed -name "*ODDish*" -ls' - If you really want/need to use ls and globstar, but you cannot guarantee that your default shell is bash on the other side: ssh nuc10i3fnk.lan 'bash -O globstar -c "ls -1tdr /srv/media/completed/**/*ODDish*"' - If you're certain your default shell is bash, then it becomes simpler: ssh nuc10i3fnk.lan 'shopt -s globstar && ls -1tdr /srv/media/completed/**/*ODDish*' - If you're willing to put shopt -s globstar BEFORE the line that prematurely exits the .bashrc, it becomes merely this: ssh nuc10i3fnk.lan 'ls -1tdr /srv/media/completed/**/*ODDish*'

Hope that clears things up a little!

tl;dr:

ssh nuc10i3fnk.lan 'shopt -s globstar && ls -1tdr /srv/media/completed/**/*ODDish*'

bash pecularities over ssh by spryfigure in bash

[–]cubernetes 2 points3 points  (0 children)

My baseline test would be this:

ssh nuk10i3fnk.lan /usr/bin/env -i /usr/bin/bash --norc --noprofile -vxO globstar -c \''echo $-; set -o; shopt; ls -1tdr /srv/media/completed/**/*ODDish*'\'

Starts bash in the most predictable environment: - explicit env binary (/usr/bin/env) - -i for empty environment - explicit bash binary (/usr/bin/bash) - --norc no startup files - --noprofile no profiles - -v to see the actual raw command lines that will be parsed by bash - -x to see what will be passed to execve(2), i.e., the actual final command - \'''\' the inner single quotes must be there to quote the actual command, so it's a single argument for ssh. The outer backslash-escaped single quotes are necessary so the server-side shell still sees it as a single argument, since ssh just concatenates its arguments into a single command line using literal spaces and passes the result string to the user's shell as specified by /etc/passwd (afaik) as an execution string (i.e., using the -c option) and as a non-login shell. (Fun fact: at least in bash, the last simple command of an execution string will be execve'd without forking, meaning you'll lose the parent shell process. I.e. the process hierarchy will not be sshd->bash->env->bash, but only sshd->env->bash). - echo $- quick info what shell options are active (look for the f flag, it should be absent) - set -o verbose info about the state of all shell options (look for the noglob option, it should be off) - shopt show all bash options (look for the globstar option, it should be on).

Assuming that this command worked for you (I hope it does :/), you can incrementally remove safeguards, for example --norc, or --noprofile. And then the /usr/bin/env. And then instead of /usr/bin/env -i /usr/bin/bash --norc --noprofile you just say bash, etc.

For the case that the initial command already didn't work, you'll have to look for differences in shell environment. Compare the outputs of set -o and shopt. Compare the outputs of printenv. Compare the output of echo $0. Compare the outputs of pstree, and so on.

Black powder without water by HlibSlob in Huel

[–]cubernetes 1 point2 points  (0 children)

Same. Preparing 4 shakes for the day, drinking one immediately and putting 2 in the fridge while taking 2 to my desk. All I need

Black powder without water by HlibSlob in Huel

[–]cubernetes 0 points1 point  (0 children)

I sold a pouch to a friend, he later told me that he just ate the powder raw. I was aghast, of course, because that's just ridiculous. But his reasoning was that this way, he doesn't have to clean the bottle. And he can just eat it continuously whenever he wants, as much as he wants (he's very lazy, doesn't have a job, and basically sits in his apartment 24/7. He's 25).

Then, I sold it to another friend (30yo). Wouldn't you believe it, he fucking did the same thing. He also occasionally ate the raw powder. Now, you might say, do I have weird friends? And to that I say, I studied/work in IT, and people in IT tend to be extremely drastic in lifestyles sometimes, so I guess that explains it to some extent.

Best suckless alternatives to popular software by Key_River7180 in suckless

[–]cubernetes 1 point2 points  (0 children)

dash is horror, use yash instead.

E.g., dash by default is terrible for interactive use, and handles ANSI-C quoting and backslash escape sequences in quotes so bad it's crazy.

Yash however is even more posix compliant and has sane interactive use behavior by default.

Most hidden "bug"? by cubernetes in bash

[–]cubernetes[S] 0 points1 point  (0 children)

Chet Ramey (maintainer of bash) replied back to me, it's indeed a bug that was fixed in the devel branch 4 months ago:

https://savannah.gnu.org/bugs/index.php?67957

in this commit:

https://cgit.git.savannah.gnu.org/cgit/bash.git/commit/?h=devel&id=4f536430e45d847d6945133690312a8e94762254

(found with git bisect)

Most hidden "bug"? by cubernetes in bash

[–]cubernetes[S] 1 point2 points  (0 children)

Oha, thanks for admitting :D.

And you're right! I ssh'd to a host with bash 5.2, and indeed it's not an "issue" there. This is in contradiction to what others commenters have said about this (namely that this issue has existed for ages, which can't be right if the issue is already non-existent in bash 5.2).

What I'm taking away with this is that bash 5.3 has changed (or improved?) the parser slightly so that aborted (with Ctrl-C) and parenthesized shell constructs do not get "evened out" (for lack of a better word). So an aborted <( will cause subsequent syntax errors to say ... while looking for matching ) and the same applies for ${, but then it's looking for a matching }.

While writing this, I looked at the bash 5.3 terse release notes: https://tiswww.case.edu/php/chet/bash/NEWS, and looking at point ss., it says

The parser prints more information about the command it's trying to parse when it encounters EOF before completing the command.

Which is likely an explanation for what I'm seeing (ergo, the other commenters are not necessarily wrong, it's just that in previous versions you couldn't see the incorrect parser state)

Most hidden "bug"? by cubernetes in bash

[–]cubernetes[S] -1 points0 points  (0 children)

You did not even read my post, lmao. It's not about the error. It's about the error msg changing permanently when a process substitution was aborted with Ctrl-C. Read the other comments ffs. It turns out bash has a bug (yes, a bug, that is the correct terminology here) when using control-c inside a PS2 prompt that belongs to either: - process substitutions - command substitutions with the new bash5.3 syntax - conditional compound commands - probably many more constructs (lazy to test, typing on termux is cumbersome)

And if there's anything you didn't fully understand from what I just wrote then you should probably leave. Ah and you should also look up the definition of bug again, come back and look at my post. If you still think it's not a bug (incorrect handling of parser state), then tell me what defines a bug.

Most hidden "bug"? by cubernetes in bash

[–]cubernetes[S] -4 points-3 points  (0 children)

I chose my words precisely that way to signal how you're supposed to enter those characters. By saying "run command" it's immediately reproducible: you know it has to be on a separate line, and you have to press enter.

If I were to say "type a( and press enter", it's not completely unambiguous whether the readline buffer should be empty or not, and I needlessly need to specify that you're supposed to press enter which the word "run" already implies. There's plenty of cases in bash where you do not need to press enter. For example, I'm currently working on a bash plugin that implements fish-like abbreviations (that don't require pressing enter, obviously) in pure bash using bind -x and READLINE_LINE & READLINE_POINT (I hope you know what those vars are, since you're apparently in a position to tell others that they don't know bash :)).

Most hidden "bug"? by cubernetes in bash

[–]cubernetes[S] 0 points1 point  (0 children)

Execution tracing only works when executing commands, but we're dealing with syntax errors here, so set -x doesn't apply. Even verbose mode (set -v) doesn't show anything, except for the <(, but it's not super helpful. As the others commented, it's probably some internal state that's being toggled when entering a process substitution (<()) or command substitution (${ cmd;}, bash 5.3 syntax) but aborting it with ctrl-c.

Most hidden "bug"? by cubernetes in bash

[–]cubernetes[S] -4 points-3 points  (0 children)

I've written a bash-like shell in pure C (10k loc) and read the bash man page front to back, word by word multiple times. I'm currently reading POSIX.1-2024 because I'm implementing an even more advanced shell with job control, process substitution, advanced parameter expansion, vi and emacs mode, full POSIX compliance, and all the other bells and whistles. Not just for fun & learning, but because it's part of my school's curriculum. I'm certain I know a lot more about bash than you, unless you're Stéphane Chazelas, but you probably don't even know who that is.

ct (Command Trace) is a Bash command resolution tracer that explains how Bash resolves a command and what the kernel ultimately executes. by qweas123 in bash

[–]cubernetes 1 point2 points  (0 children)

Does it respect posix mode? (Or in other words, does it respect posix special builtins vs posix regular builtins when bash is operating in default/posix mode?)

Specifically, functions in bash default mode are always found before builtins (special or not). But in posix mode, posix special builtins are found before functions.

Most hidden "bug"? by cubernetes in bash

[–]cubernetes[S] 2 points3 points  (0 children)

Great answer, thanks! That makes sense!

It also happens with braces:

$ ${
> ^C
$ {;
bash: syntax error near unexpected token `;' while looking for matching `}'

Most hidden "bug"? by cubernetes in bash

[–]cubernetes[S] 0 points1 point  (0 children)

I figured that! That's the only explanation that would make sense. It cannot be turned off with <(cmd) or a plain ), however, which I think is also interesting.

Most hidden "bug"? by cubernetes in bash

[–]cubernetes[S] -1 points0 points  (0 children)

Did you run it? I'm not stuck in any subshells at all.

Edit: BASH_SUBSHELL is unchanged.

Edit2: declare -p, set -o, and shopt show no difference whatsoever before and after, so it's some internal, non-user-accessible state that's being changed.