Page 2 of 2
Re: Sourcing from Konsole Subshell results in Syntax Errors
Posted: 04 May 2015, 04:28
by Rava
Just realized, I can edit the initial post, but I don't see any button for moving a thread into another sub-forum... Do I just miss that, or is that something only admins can do?
I use custom colours in palemoon, disallowing all sites to use their own colours, and some sites, like phpBB and others have a bug, and all links like [mit Zitat antworten] [Information] or [Benutzer verwarnen] are plain and only black buttons on black background. I
have to know where the links are, more or less, hovering the mouse there gives me the popup info if I am hovering at the right button, or not. Then I can e.g. "reply with quote" </non Porteus bug>
So, it can happen that I miss links, cause having issues seeing completely black buttons on black background.
Re: Sourcing from Konsole Subshell results in Syntax Errors
Posted: 04 May 2015, 05:36
by ncmprhnsbl
but I don't see any button for moving a thread into another sub-forum...
bottom right hand page corner is 'quick mod tools', a box saying 'lock topic' and a 'go' button
click on 'lock topic' and a drop down menu with more options appears...including move topic
not entirely obvious even when you can see it..
Re: Sourcing from Konsole Subshell results in Syntax Errors
Posted: 04 May 2015, 09:15
by Rava
ncmprhnsbl wrote:bottom right hand page corner is 'quick mod tools', a box saying 'lock topic' and a 'go' button
click on 'lock topic' and a drop down menu with more options appears...including move topic
not entirely obvious even when you can see it..
Sounds like I have to temporarily switch all pages to allow/show their own colours
(like, once again <le regular yawn>), then I sure will see it.
... But it's a
good mind training, when I have to recall the unseen, hidden exact location of yet another hidden buttons to be used regularly... Yay for brain training!
Re: Sourcing from Konsole Subshell results in Syntax Errors
Posted: 04 May 2015, 12:33
by Bogomips
Another Way: Viewing topic > Moderator Control Panel > Moderate Topic 8)
Re: Sourcing from Konsole Subshell results in Syntax Errors
Posted: 04 May 2015, 17:08
by Rava
Moved thread to "programming", since it is about script coding, and not about KDE.
Very Similar Subshell Bug
Posted: 25 Aug 2016, 20:54
by Bogomips
Code: Select all
uest@porteus:~$ sh mksavfile.sh
mksavfile.sh: line 36: syntax error near unexpected token `<'
mksavfile.sh: line 36: ` read used < <(df -BM --output=used $u|tail -n1); usd0=${used%M};'
guest@porteus:~$ chmod a+x mksavfile.sh
guest@porteus:~$ mksavfile.sh
bash: mksavfile.sh: command not found
guest@porteus:~$ ./mksavfile.sh
Usage: sh mksavfile.sh [/Path/to/]Savefile [ <Size of file in MB> [ Block size for XFS ] ]
Re: Sourcing from Konsole Subshell results in Syntax Errors
Posted: 13 Oct 2016, 12:27
by Bogomips
Resolved- !st Issue
Code: Select all
guest@porteus:~$ echo PID of Shell: $$
PID of Shell: 2484
guest@porteus:~$ mkdir pk01
guest@porteus:~$ cd pk01/
guest@porteus:~/pk01$ sh
guest@porteus:~/pk01$ . ../p10/Por/Komodo/funcs.sh
sh: ../p10/Por/Komodo/pakdep.sh: line 208: syntax error near unexpected token `<'
sh: ../p10/Por/Komodo/pakdep.sh: line 208: ` readarray -t req < <( cat reqmts )'
sh: ../p10/Por/Komodo/pak.sh: line 37: syntax error near unexpected token `<'
sh: ../p10/Por/Komodo/pak.sh: line 37: ` readarray -t vec < <(cat ${1%.pak}.pak) # Allow for auto-completion 2015-04-25 17:05:03'
sh: ../p10/Por/Komodo/selpak.sh: line 29: syntax error near unexpected token `<'
sh: ../p10/Por/Komodo/selpak.sh: line 29: ` readarray -t rps < <( cat ${rq}_ar.rep )'
guest@porteus:~/pk01$ exit
guest@porteus:~/pk01$ echo PID of Shell: $$
PID of Shell: 2484
guest@porteus:~/pk01$ bash
guest@porteus:~/pk01$ echo PID of Shell: $$
PID of Shell: 2645
guest@porteus:~/pk01$ . ../p10/Por/Komodo/funcs.sh
guest@porteus:~/pk01$ exit
- 2nd Issue
Code: Select all
guest@porteus:~$ sh mksavfile.sh
mksavfile.sh: line 38: syntax error near unexpected token `<'
mksavfile.sh: line 38: ` read used < <(df -BM --output=used $u|tail -n1); usd0=${used%M};'
guest@porteus:~$ bash mksavfile.sh
Usage: mksavfile.sh [/Path/to/]Savefile [<Size of file in MB>[Block size for XFS]]
Re: Sourcing from Konsole Subshell results in Syntax Errors
Posted: 13 Oct 2016, 17:57
by port
Rava wrote:Bogomips wrote:Think there has been a bit of a misunderstanding here. What I meant was that I got the instruction from the Internet, and which I'm now using in my script. Not sure if this is the exact url, but the statement is very much the same
Code: Select all
$ read test < <(echo hello world)
$ echo $test
hello world
It's answer #14 at
http://stackoverflow.com/questions/2746 ... stdin-pipe
Ohhhhh I see, now that's something new to me... I have to find other occurences of that very syntax to fully understand it... *le dramatic sigh*
for your interest if any, that syntax is called
process substitution and in simply words it works providing the result of command execution (input if >() or output if <()) as a file you can use in place of any common file, in particular in shell redirection
so, a command like
allows you to show the contents of the root directory (directory listing, ls), as the same way you display the content of any other common file such as cat ~/.bashrc
You may wonder how it works or exactly what file are you displaying with that command, the answer is you're display a temporary file, that's how it works:
so when invoking
cat <(ls) you are displaying the contents of temporary file
/proc/self/fd/11 It's exactly the same mechanism of named pipes but it's done authomatically by the shell
You may wonder if it is these two command are the same:
and the answer is almost the same, the result for both commands is the same, you show the listing of current directory, but the first one uses the same shell for the only process while the latter uses two subshells one for each command which is slighty but important difference.
Of course you can use it also combined with redirection:
Code: Select all
$ cat | tr ' ' '-'
var name with spaces
var-name-with-spaces
$ tr ' ' '-' < <(cat)
var name with spaces
var-name-with-spaces
Re: [Solved] Sourcing in Konsole Subshell gives Syntax Error
Posted: 13 Oct 2016, 19:38
by Bogomips
Code: Select all
guest@porteus:~$ read s <(ls)
bash: read: `/dev/fd/63': not a valid identifier
guest@porteus:~$ echo <(ls)
/dev/fd/63
guest@porteus:~$ echo <(ls /)
/dev/fd/63
Re: [Solved] Sourcing in Konsole Subshell gives Syntax Error
Posted: 14 Oct 2016, 03:22
by port
Bogomips wrote:Code: Select all
guest@porteus:~$ read s <(ls)
bash: read: `/dev/fd/63': not a valid identifier
guest@porteus:~$ echo <(ls)
/dev/fd/63
guest@porteus:~$ echo <(ls /)
/dev/fd/63
read command reads from standard input not from file, so the right syntax for your command is:
Code: Select all
$ ls
amp.fzz fossil PCB.00006003.backup
$ read s < <(ls)
$ echo $s
amp.fzz
remember that process substitution may be replaced by a common file so if you need file redirection you must include redirection operator as well
Re: [Solved] Sourcing in Konsole Subshell gives Syntax Error
Posted: 14 Oct 2016, 12:22
by Bogomips
@port
Thanks for the heads up on process substitution being replaced by a temporary file.
The aim here was to show this best illustrated by the error message:
Code: Select all
guest@porteus:~$ read s <(ls)
bash: read: `/dev/fd/63': not a valid identifier
Process Substitution
Process substitution is supported on systems that support named pipes (FIFOs) or the /dev/fd method of naming open files. It takes the form of <(list) or >(list). The process list is run with its input or output connected to a FIFO or some file in /dev/fd. The name of this file is passed as an argument to the current command as the result of the expansion. If the >(list) form is used, writing to the file will provide input for list. If the <(list) form is used, the file passed as an argument should be read to obtain the output of list.
When available, process substitution is performed simultaneously with parameter and variable expansion, command substitution, and arithmetic expansion.
Re: [Solved] Sourcing in Konsole Subshell gives Syntax Error
Posted: 15 Oct 2016, 05:44
by port
@Bogomips you're welcome I was just trying to introduce an easy image to remember the right use of process substitution
Bogomips wrote:
The aim here was to show this best illustrated by the error message:
Code: Select all
guest@porteus:~$ read s <(ls)
bash: read: `/dev/fd/63': not a valid identifier
Process Substitution
Process substitution is supported on systems that support named pipes (FIFOs) or the /dev/fd method of naming open files. It takes the form of <(list) or >(list). The process list is run with its input or output connected to a FIFO or some file in /dev/fd. The name of this file is passed as an argument to the current command as the result of the expansion. If the >(list) form is used, writing to the file will provide input for list. If the <(list) form is used, the file passed as an argument should be read to obtain the output of list.
When available, process substitution is performed simultaneously with parameter and variable expansion, command substitution, and arithmetic expansion.
yes, that's the point, for that reason I said it's the same as named pipes but done automathically by the sell, very well explained in that quote