It seems you're comparing versions. In PowerShell and .NET framework there are already [version]
to do that:
PS C:\Users> [version]"2.5.7" -le [version]"2.5.6"
False
PS C:\Users> [version]"2.4.10" -lt [version]"2.4.9"
False
PS C:\Users> [version]::new(2, 4, 8) -lt [version]::new(2, 4, 10)
True
PS C:\Users> [version]"2.5.6" -le [version]"2.5.6"
True
PS C:\Users> [version]::new(2, 5, 6) -lt [version]::new(2, 5, 6)
False
See PowerShell Comparison Operators for more information
Note that Windows Terminal is a terminal and can't run anything. Same to other terminals like conhost (the default terminal on older Windows), term, xterm, iterm, konsole... The thing that runs commands is called the shell and a shell must be connected to some terminal to work. So saying "running in Windows Terminal" makes almost no sense because the error comes from the shell. Your command is a bash command so obviously if you run bash in Windows Terminal then it'll run properly. It's unclear which shell you're using but
- In PowerShell
[ "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ]
completely fails to parse because in PowerShell `
is an escape character (which means your command doesn't terminate), and =
, [
/]
in PowerShell are an operator instead of a normal character like in bash
- In cmd
$
isn't the character for variable and argument substitution, and `
also has no special meaning, so if there's a [.exe
in your path then cmd will pass the whole literal command to the [
command which will fail to compare anything
Each shell has its own syntax, don't try to run commands written for a shell on another completely different one