last day (14 days later) » 

11:49
6
A: Tell me my screen resolution!

manatworkBash + xrandr, 44 characters read -aa<<<`xrandr` echo ${a[7]}x${a[9]::-1} xrandr belongs to the X server, on Ubuntu is provided by x11-xserver-utils package. Sample run: bash-4.3$ read -aa<<<`xrandr`;echo ${a[7]}x${a[9]::-1} 1920x1080

I have no bash with a display, would xrandr|grep * work?
Maybe xrandr|grep *|cut -d' ' -f1? (using the matching line from your paste @TIO)
Ah yes it would, not sure what the OP wants in such a scenario though!
@JonathanAllan No, it wouldn't. An unescaped * is a glob that the shell expands to all files in the CWD.
@Jens huh it wouldn't what?
@JonathanAllan Work. Like you asked in your first comment.
What?! xrandr|grep * should not treat * as a glob as it's post-pipe :/
11:49
@JonathanAllan Since when does the shell not glob expand after a pipe sign? That page you linked to with man man|grep * is crap.
@Jens That page is TIO, run by Dennis, one of the mods, It is running BASH.
are you running BASH somewhere? Have you tried it?
If your instance does not work then yeah you'd need ...|grep \* for a byte
but it only needs to work on some instance somewhere :p
I don't judge the quality of code by who wrote it. I judge by whether it does what it should. No, I haven't tried it, because I know how globbing works. But if seeing is believing: what does xrandr|echo * output on your machine?
It wont output anything on my machine I am on Windows mate.
bash on windows does not do globbing? Then it's broken.
I have no bash
and I do not know what it's SUPPOSED to do either
but shouldn't a pipe actually pipe?
i.e. run a command and pipe the output into another?
12:01
Yes it does. But commands in pipes can have arguments as well. And the shell expands globs BEFORE it starts any program in the pipeline.
The reason I said who is running it is so you can ask someone who actually knows this stuff and could explain why it is doing what it does AND fix it if it is wrong
weird that manatwork said "sure"
I'm on the POSIX comitte for Shell Standardization, if that means anything :-)
nope sorry means nothing to me "hand over head"
OK looked up "POSIX"
does not mean you should go around saying stuff is "crap"
Well, all I can says is that command|grep * expands the * in any shell and that is almost certainly not what the author intended. Glob expansion is suppressed by quoting.
most online bash will say man is unrecognised
12:05
I apologize for the harsh word.
the author is running some BASH...
so if it is wrong you can let him know!!
Does not matter. All Bourne shells behave the same in this regard.
maybe in the TryItOnline chat room
so why is it doing that then?
it is such a shell
Beats me. Maybe it's a markup problem, swallonging the quoting?
OK well I'll let him know then
12:07
Thanks, that would be helpful.
xrandr|echo * yields *
It yields empty here.
but xrandr will fail I believe
because no display it connected
but man man|echo * also yields *
Ok there is one exception, when globbing does not happen: when set -f (no filename expansion) is in effect. But the default for that is off.
NIX is so complicated LOL
12:11
I wouldn't touch a Windows shell with a ten foot pole :-)
you never need to though
I'm using Cygwin where I can, with zsh.
Mate, I need to work... nice having a chat with you :-)
I have deleted my harsh comment.
no problem, I wish I could understand NIX :p
12:30
@jens FYI the reason it works is because there are no files in the CWD.
so I guess it would be a valid submission to not escape it, just needs to be in it's own dir :p

last day (14 days later) »