« first day (3220 days earlier)      last day (2028 days later) » 

Tim
Tim
00:11
I also saw an interesting movie today
I don't quite understand it though...
@Ungeheuer It's gone now.
 
5 hours later…
05:16
06:00
@derobert You'd think he could come up with something a little more obscure than Terminator as an example. There are tens of thousands of films/movies.
@derobert Also, Tomatometer or Audience Score?
 
7 hours later…
13:21
printf 'This i%s %sparta\n' 's a good morning' 'to all, especially those living in Es'
 
2 hours later…
15:02
anyone see anything wrong with "rounding" number in this manner?
printf '%3i%% - %i\n' "$i" "$(get_percent "$i" "$max")" 2>/dev/null
I don't particularly care about rounding up or down simply converting floats to integers
( $(get_percent "$i" "$max") can return floating point numbers )
15:33
I guess I could just use %.0f
 
1 hour later…
16:48
@MichaelHomer you should know. Has there been a version of bash where this would work?
while read var; do something; done < $(command)
I'm having a friendly argument with a user on SO.es who claims that while inelegant, that did actually work for him on bash v <4. And I find that very hard to believe.
Might they have used < <(command) rather than < $(command) (and misremembered)?
@EliahKagan No, because this is in response to a comment I left pointing out precisely that they should use < <(command) instead of < $(command).
$ /bin/bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin18)
Copyright (C) 2007 Free Software Foundation, Inc.
$ /bin/bash -c 'while read n; do echo $n; done < $(seq 1 5)'
/bin/bash: $(seq 1 5): ambiguous redirect
Oh. Hmm.
See the edit history here:
@Jesse_b Ah! Thanks.
I can't imagine it ever working. While needs a file, not a string.
16:54
It probably used to work when they used the proper syntax that they now forget
Something like that. I was just intrigued in case I was just missing something.
Wouldn't have been the first time.
If the output of command is a filename, and that's the filename that one wishes to read from, then the redirection < $(command) could work, though I would write it < "$(command)". It doesn't look like that really applies to the situation described there, though.
@EliahKagan Good point
@EliahKagan Yes, that would work indeed, it would just do something else.
he just told me he tested on a mingw environment under windows.
Maybe it works there then. How odd.
I've never even heard of that
17:03
What's more interesting, is that different shells give different errors.
$ checkshell 'while read var; do echo $var; done < $(seq 3)'
bash	:      bash: $(seq 3): ambiguous redirect
csh	:      Illegal variable name.
dash	:      dash: 1: cannot open 1
2
3: No such file
fish	:      fish: Missing end to balance this while loop
while read var; do echo $var; done < $(seq 3)
^

git-shell	:      fatal: unrecognized command 'while read var; do echo $var; done < $(seq 3)'
ksh	:      ksh: 1
2
3: cannot open [No such file or directory]
mksh	:      mksh: can't open 1
2
3: No such file or directory
Or, limiting to the shells that actually support command substitution and that while loop format:
bash	:      bash: $(seq 3): ambiguous redirect
dash	:      dash: 1: cannot open 1
2
3: No such file
mksh	:      mksh: can't open 1
2
3: No such file or directory
sh	:      sh: $(seq 3): No such file or directory
yash	:      yash: redirection: cannot open file `1
2
3': No such file or directory
zsh	:      zsh:1: no such file or directory: 1
I would expect bash to give an error more similar to the one dash gives if one runs bash in POSIX mode. When bash is not in POSIX mode, it rejects attempts to redirect with a filename produced by an expansion on which word splitting occurs and produces multiple words. IIRC "ambiguous redirect" is the error message it gives in that situation.
@EliahKagan Yes, the sh there is bash in POSIX mode.
And yes, word splitting should explain why I get different errors here:
Ah, right. I am so accustomed to /bin/sh being dash, as in Debian and Ubuntu.
terdon@tpad foo $ while IFS= read -r line; do  echo "$line" ; done < $(seq 1)
bash: $(seq 1): No such file or directory
terdon@tpad foo $ while IFS= read -r line; do  echo "$line" ; done < $(seq 2)
bash: $(seq 2): ambiguous redirect
So in the first case, it tries to open a file called 1 and fails with "no such file". Why is the second one ambiguous though?
I'm guessing it's something to do with word splitting as you said, and the presence of the newline, but why ambiguous?
$ while read var; do echo $var; done < $(perl -e 'print "foo" x 100')
bash: $(perl -e 'print "foo" x 100'): File name too long
$ while read var; do echo $var; done < $(perl -le 'print "foo"')
bash: $(perl -le 'print "foo"'): No such file or directory
$ while read var; do echo $var; done < $(perl -le 'print "foo\nbar\n"')
bash: $(perl -le 'print "foo\nbar\n"'): ambiguous redirect
I think it's considered ambiguous because the user might mean that no word splitting should happen, or might mean that split words should be rejoined, or might mean that all but the first word are intended as arguments to the command. Writing "$(seq 2)" instead of $(seq 2) should avoid that error.
17:20
Yes, quoting results in the file not found error.
$ while IFS= read -r line; do  echo "$line" ; done < "$(seq 2)"
bash: $(seq 2): No such file or directory
The same happens with parameter expansion (in place of command substitution):
ek@Kip:~$ x='foo bar'
ek@Kip:~$ : < $x
-bash: $x: ambiguous redirect
ek@Kip:~$ : < "$x"
-bash: foo bar: No such file or directory
What's even curiouser is that, apparently, on the user's Linux system (he just tested) it gives him a filename too long error but prints out the contents of the file in reverse before giving the error. He says he used this script:
in Discussion between terdon and Patricio Moracho, 15 mins ago, by Patricio Moracho
#!/bin/bash

while IFS= read -r line; do
echo "$line"
done < "$(tac test.html)"
That's... strange.
very
I wish I knew the user better, I don't want to badger the poor guy and he's been very nice in accommodating my curiosity.
Yeah.
I've gotta run, but I might try to reproduce that behavior later. I wonder if some versions of some shells might put the whole output of tac in the error message about the filename being too long, or something.
17:25
Ah! Yes, that makes sense.
yash puts the whole thing in the error, but complains about not being able to open it rather than its being too long.
So do dash, ksh and mksh
By the way, if anyone's interested, that checkshell function I used is:
checkshell ()
{
    awk -F"/" '!/^#/ && NF>1{print $NF}' /etc/shells | sort | uniq | while read s; do
        printf '%s\t:      ' "${s##*/}";
        "$s" -c "$@";
    done
}
@EliahKagan That's almost certainly it.
Thanks, that was bugging me :)
18:28
@terdon Wouldn't it be better to leave all the shells though?
In my case I have 3 separate installs of bash but all with different versions
I guess it would be difficult to know which is which though
18:44
1
Q: Stack creation - How to assign an inline policy to adhoc user?

overexchangeBackground: With cross account role someaccountrole, I have access to aws account xyz. Case 1 To create a stack in account xyz, we upload the Cloudformation file through console. Amidst stack creation in Events tab, we see the very first event, as shown below: Case 2 We create EC2 in...

 
1 hour later…
19:54
@MichaelHomer Nice!
I finally posted my xorg.conf question here unix.stackexchange.com/questions/533745/…. I have several attempted xorg.conf files, and xrandr output that could useful to post, but I'm not sure how they can be posted without creating a giant wall of text, or via links that will be forever persistent.
Any suggestions on how to get that content into the question, or if it's really needed?
@Jesse_b yes, good point. I just wrote that to test U&L answers and I don't have multiple versions installed. Should be feasible with - - version though
@terdon Yeah but I think --version is mostly a gnu thing, no? I don't know if many of the other shells would support it
No idea. I'll play with it though, should be fun :)
well it looks like all my shells do
that being said it took powershell like 45 seconds to return it's version lol
20:49
@terdon I don't have a Bash 1 around to check, but... no
I think you correctly diagnosed it as somebody who doesn't know what an error message is

« first day (3220 days earlier)      last day (2028 days later) »