|
Post by vovchik on Feb 17, 2020 10:34:48 GMT 1
Dear Joe, Brilliant and thanks! We are amost there. It does set the environment, and this works: bish setenviron "BISH" "V0.1g" && bish getenviron "BISH" but, in a script, this doesn't: #!/bin/bash
bish setenviron "BISH" "V0.1g" echo "---" bish getenviron "BISH" Once that works, I think we can use a similar technique for CHANGEDIR, which is not yet working. With kind regards, vovchik
|
|
|
Post by bigbass on Feb 18, 2020 8:06:32 GMT 1
Hello vovchik
all that you do in bish is its own shell every time you start a new instance of bish it has its own local env
you pointed out that you can chain commands together with && but as soon as you start a new shell those values are lost
we could send those values to a temp file then source the file to have it available to us and some filtering of duplicate entries
anyway this is just an experimental bish only editing the get and setenv with the tmp file called var2.txt
I will delete it after you get a copy (its only for testing the idea )
Joe
|
|
|
Post by vovchik on Feb 18, 2020 9:10:46 GMT 1
Dear Joe, Thanks. I have it downloaded and will look now... This could be a good solution for saving some interprocess info. Or we use the clipboard. With kind regards, vovchik
|
|
|
Post by vovchik on Feb 18, 2020 17:14:30 GMT 1
Dear Joe, Your idea - using a tmp file for saving the environment is a good one. I am palying with a few implementation schemes and should soon have some kind of workable solution within bish. It is a poor man's IPC, but we don't really need anything too complex. This is one approach to grabbing the environment with a new variable: BISH$ = "BISH" SETENVIRON BISH$, "XXX" SYSTEM "declare -px | grep BISH | cut -f3 -d' ' > /tmp/bish_env" We can then read /tmp/bish_env it back with the next bish invocation, and set it as an environmental var, so that it will be available to the new bish as a variable. What do you think? With kind regards, vovchik
|
|
|
Post by bigbass on Feb 18, 2020 17:27:38 GMT 1
Hello vovchik
Yes , along those lines is the main idea and sourcing the end result after its parsed so it could be reused
just having some "virtual memory" to enhance the power of bish
here is something you could add to bish (in whatever way you wanted) or just use the idea for something to add to your bish.inc file idea
as long as we are having fun with it good things will come into focus I modded it so it should just drop in with your bish code syntax and use the variables in your code
Joe
'--- undocumented tricks '--- by bigbass June 13 2013 '--- updated code 2020 to use setenv and <gnu/libc-version.h>
PRAGMA INCLUDE <string.h> <stdio.h> <gnu/libc-version.h> PRAGMA LDFLAGS PRAGMA COMPILER gcc PRAGMA OPTIONS -Wno-write-strings -Wno-pointer-arith
OPTION PARSE FALSE PROTO setenv getenv
DECLARE result$ TYPE STRING DECLARE selected TYPE STRING DECLARE ENV_VAR2 TYPE STRING DECLARE cmd_result$ TYPE STRING
DECLARE BACON_V TYPE STRING DECLARE LIBC_V TYPE STRING DECLARE GTK2_V TYPE STRING DECLARE GTK3_V TYPE STRING DECLARE KERNEL_V TYPE STRING DECLARE MACHINE_V TYPE STRING
'====================================== '--- Current BaCon release '====================================== result$= EXEC$("bacon -v" ) BACON_V = result$
'--- convert to local environmental syntax
setenv("BACON_V",BACON_V,1) '--- now it is a local environmental variable in bacon and bash cmd_result$ = EXEC$("echo $BACON_V") PRINT cmd_result$ FORMAT "%s\n"
'====================================== '---Current LIBC release '====================================== result$ = gnu_get_libc_version() '--- convert to local environmental syntax LIBC_V=(char*)result$
setenv("LIBC_V",LIBC_V,1) '--- now it is a local environmental variable in bacon and bash cmd_result$ = EXEC$("echo $LIBC_V") PRINT cmd_result$ FORMAT "%s\n"
'====================================== '--- Current gtk2 version '====================================== result$= EXEC$("cat /usr/lib/arm-linux-gnueabihf/pkgconfig/gtk+-2.0.pc | grep Version:" ) GTK2_V = (char*) result$
'--- convert to local environmental syntax
setenv("GTK2_V",GTK2_V,1) '--- now it is a local environmental variable in bacon and bash cmd_result$ = EXEC$("echo $GTK2_V") PRINT cmd_result$ FORMAT "%s\n"
'====================================== '--- Current gtk3 version '====================================== result$= EXEC$("cat /usr/lib/arm-linux-gnueabihf/pkgconfig/gtk+-3.0.pc | grep Version:" ) GTK3_V = (char*)result$ '--- convert to local environmental syntax
setenv("GTK3_V",GTK3_V,1) '--- now it is a local environmental variable in bacon and bash cmd_result$ = EXEC$("echo $GTK3_V") PRINT cmd_result$ FORMAT "%s\n"
'====================================== '--- machine type the system is running on. '====================================== result$= EXEC$("uname -m" ) MACHINE_V = (char*)result$ '--- convert to local environmental syntax
ENV_VAR2 = "MACHINE_V" setenv("MACHINE_V",MACHINE_V,1) '--- now it is a local environmental variable in bacon and bash cmd_result$ = EXEC$("echo $MACHINE_V") PRINT cmd_result$ FORMAT "%s\n"
'====================================== '--- kernel type the system is running on. '====================================== '--- kernel the system is running on. result$= EXEC$("uname -r" ) KERNEL_V = (char*) result$ '--- convert to local environmental syntax
setenv("KERNEL_V",KERNEL_V,1) '--- now it is a local environmental variable in bacon and bash cmd_result$ = EXEC$("echo $KERNEL_V") PRINT cmd_result$ FORMAT "%s\n"
BaCon version 4.0 on Linux armv7l - (c) Peter van Eerten - MIT License.
2.28
Version: 2.24.32
Version: 3.24.5
armv7l
4.19.75-v7+
|
|
|
Post by vovchik on Feb 19, 2020 16:44:00 GMT 1
Dear Joe,
I will work on those ideas - which will make bish a more general-purpose tool (a kind of Swiss knife). Thanks. In the meantime, I have implemented clip_copy and clip_paste, enabling very primitive data exchange between bish invocations in a script (or in a balias type script). Things like this work now:
$(bish clip_copy<<<"TEXT2 TO CLIPBOARD") && bish lcase <<< $(bish clip_paste)
The latest version of bish is in the first post.
With kind regards, vovchik
|
|
|
Post by bigbass on Feb 19, 2020 17:55:39 GMT 1
Hello vovchik
I simplified the getenv in my above post it is standalone code it would be better to see whats going on first before adding it to bish later
output should be like this without any quotes or = sign
works if you are on the raspberry pi for GTK2 and GTK3
BaCon version 4.0 on Linux armv7l - (c) Peter van Eerten - MIT License.
2.28
Version: 2.24.32
Version: 3.24.5
armv7l
4.19.75-v7+
P.S I am working on a fix for changedir the idea is (the workaround to this complex problem of the built in cd) is we can save a prefix name then run all commands with that prefix
that would simulate what the cd does anyway without having to fork
Joe
|
|
|
Post by bigbass on Feb 20, 2020 5:46:10 GMT 1
Hello vovchik
I got the changedir working But it does not use the official bacon command at all
many reasons why and its no fault of bacon it is a cause and effect of running from a shell then trying to change the parent directory from the child shell
it is a hack of doing what needs to be done by the cd command without ever using the cd command
took some time to get it to work and an added plus we can run a command on a new directory
# an undocumented change directory then run a command ! ./bish changedir bacon_trunk cat README.1ST
have fun this is an "experimental test only" please use vovchik's bish for official use will delete again once you get a copy
Joe
|
|
|
Post by vovchik on Feb 20, 2020 13:09:53 GMT 1
Dear Joe,
Thanks. I downloaded it and am studying the code...
With kind regards, vovchik
|
|
|
Post by bigbass on Feb 20, 2020 17:39:28 GMT 1
Hello vovchik
just to keep things clean from now on I will always take whatever is your latest bish.bac from page 1 and add to that so at least I know it will compile and run with the changes I make
this way if something is useful to you it would be easy to test without having to copy and paste and hope nothing is missing I could also paste a diff whatever seems easier
this is a cleaned up version that automatically sorts the output file as you go
P.S I found a bug with the command SYSTEM and had to use the real system using PROTO didnt look at the why yet just wanted you to be aware of it Joe
same thing goes I will delete this also (you did an excellent job with bish I just want to help out)
|
|
|
Post by vovchik on Feb 21, 2020 12:32:51 GMT 1
Dear Joe,
Thanks for all the help and ideas. I am still working out the environment bits and testing. In the meantime, I have added EXCERPT, which is useful, among other things, for parsing code. I left a long explanation of what it does in the bish source. I also eliminated dependencies for the fake clipboard - and just use a file in /tmp, without recourse to xsel or xclip. The new bish is in the first post.
With kind regards, vovchik
|
|
|
Post by vovchik on Feb 22, 2020 16:29:37 GMT 1
Dear Joe (and all),
I added an incipient UNITS function that converts various units of measure. It is far from complete, but the bits that are there seem to be working fine, so it is only a matter of rounding up some more common conversions and including them. I know there is a "units" binary in olinux, but it is not bad, I think, to have such a thing available within bish. The updated source is in the first post.
With kind regards, vovchik
|
|
|
Post by Pjot on Feb 23, 2020 10:47:37 GMT 1
Hi vovchik, I did some testing and all seems to be working pretty well. Especially the delimited string functions come handy in a shell environment. In my daily work I need them a lot. Thanks for the concept and implementation, and keep up the good work! Regards Peter
|
|
|
Post by alexfish on Feb 23, 2020 18:45:21 GMT 1
Hi Vovchik have done a html-strip as can see more work & or ideas on striping un-necessary tags like script can be applied have not done any entities decoding or any href tags to text do as You Please with the bits BR Alex Attachments:NewParse.bac.bz2 (877 B)
|
|
|
Post by vovchik on Feb 24, 2020 15:59:47 GMT 1
Dear Alex, Thanks. I turned it into a function so that it can later be integrated easily into bish. We are getting closer bit by bit... With kind regards, vovchik Attachments:html-purge.tar.gz (3.05 KB)
|
|