[Solved] Sourcing in Konsole Subshell gives Syntax Errors
- Rava
- Contributor
- Posts: 5424
- Joined: 11 Jan 2011, 02:46
- Distribution: XFCE 5.01 x86_64 + 4.0 i586
- Location: Forests of Germany
Re: Sourcing from Konsole Subshell results in Syntax Errors
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.
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.
Cheers!
Yours Rava
Yours Rava
- ncmprhnsbl
- DEV Team
- Posts: 4095
- Joined: 20 Mar 2012, 03:42
- Distribution: v5.0-64bit
- Location: australia
- Contact:
Re: Sourcing from Konsole Subshell results in Syntax Errors
bottom right hand page corner is 'quick mod tools', a box saying 'lock topic' and a 'go' buttonbut I don't see any button for moving a thread into another sub-forum...
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..
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44
- Rava
- Contributor
- Posts: 5424
- Joined: 11 Jan 2011, 02:46
- Distribution: XFCE 5.01 x86_64 + 4.0 i586
- Location: Forests of Germany
Re: Sourcing from Konsole Subshell results in Syntax Errors
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.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..
... 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!
Cheers!
Yours Rava
Yours Rava
-
- Full of knowledge
- Posts: 2564
- Joined: 25 Jun 2014, 15:21
- Distribution: 3.2.2 Cinnamon & KDE5
- Location: London
Re: Sourcing from Konsole Subshell results in Syntax Errors
Another Way: Viewing topic > Moderator Control Panel > Moderate Topic 8)
Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB
- Rava
- Contributor
- Posts: 5424
- Joined: 11 Jan 2011, 02:46
- Distribution: XFCE 5.01 x86_64 + 4.0 i586
- Location: Forests of Germany
Re: Sourcing from Konsole Subshell results in Syntax Errors
Moved thread to "programming", since it is about script coding, and not about KDE.
Cheers!
Yours Rava
Yours Rava
-
- Full of knowledge
- Posts: 2564
- Joined: 25 Jun 2014, 15:21
- Distribution: 3.2.2 Cinnamon & KDE5
- Location: London
Very Similar Subshell Bug
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 ] ]
Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB
-
- Full of knowledge
- Posts: 2564
- Joined: 25 Jun 2014, 15:21
- Distribution: 3.2.2 Cinnamon & KDE5
- Location: London
Re: Sourcing from Konsole Subshell results in Syntax Errors
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]]
Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB
-
- Samurai
- Posts: 137
- Joined: 18 Feb 2016, 09:25
- Distribution: Linux porteus 3.2.2 KDE
- Location: Spain
Re: Sourcing from Konsole Subshell results in Syntax Errors
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 redirectionRava wrote: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*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 sameIt's answer #14 at http://stackoverflow.com/questions/2746 ... stdin-pipeCode: Select all
$ read test < <(echo hello world) $ echo $test hello world
so, a command like
Code: Select all
$ cat <(ls /)
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:
Code: Select all
$ echo <(ls /)
/proc/self/fd/11
You may wonder if it is these two command are the same:
Code: Select all
$ cat <( ls )
$ ls | cat
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
-
- Full of knowledge
- Posts: 2564
- Joined: 25 Jun 2014, 15:21
- Distribution: 3.2.2 Cinnamon & KDE5
- Location: London
Re: [Solved] Sourcing in Konsole Subshell gives Syntax Error
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
Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB
-
- Samurai
- Posts: 137
- Joined: 18 Feb 2016, 09:25
- Distribution: Linux porteus 3.2.2 KDE
- Location: Spain
Re: [Solved] Sourcing in Konsole Subshell gives Syntax Error
read command reads from standard input not from file, so the right syntax for your command is: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
Code: Select all
$ ls
amp.fzz fossil PCB.00006003.backup
$ read s < <(ls)
$ echo $s
amp.fzz
-
- Full of knowledge
- Posts: 2564
- Joined: 25 Jun 2014, 15:21
- Distribution: 3.2.2 Cinnamon & KDE5
- Location: London
Re: [Solved] Sourcing in Konsole Subshell gives Syntax Error
@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:
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.
Last edited by Bogomips on 14 Oct 2016, 18:47, edited 1 time in total.
Reason: Manual Extract
Reason: Manual Extract
Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB
-
- Samurai
- Posts: 137
- Joined: 18 Feb 2016, 09:25
- Distribution: Linux porteus 3.2.2 KDE
- Location: Spain
Re: [Solved] Sourcing in Konsole Subshell gives Syntax Error
@Bogomips you're welcome I was just trying to introduce an easy image to remember the right use of process substitution
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 quoteBogomips 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.