BashDB | A Key/Value store written entirely in bash | Script Programming library
kandi X-RAY | BashDB Summary
kandi X-RAY | BashDB Summary
A Key/Value store written entirely in bash.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of BashDB
BashDB Key Features
BashDB Examples and Code Snippets
Community Discussions
Trending Discussions on BashDB
QUESTION
I teach in a Sec. School and a student in my class has come with this code, asking me why the loop never ends.
...ANSWER
Answered 2019-Jan-16 at 10:53The condition used in the while loop is everything between while
and do
. In this case, the condition includes line 3 (the echo
) which returns 0 every time. The result of the comparison is ignored and the exit status of the echo
is used, as documented in help while
:
while:
while COMMANDS; do COMMANDS; done
Execute commands as long as a test succeeds.
Expand and execute COMMANDS as long as the final command in the
while
COMMANDS has an exit status of zero.
QUESTION
This is based on another question of mine. I am trying to prevent executions of certain commands using a script. I got the script to work perfectly in interactive shells, but for noninteractive shells it doesn't prevent its execution.
/home/user/stop.sh (sourced in .bashrc)
...ANSWER
Answered 2018-Feb-14 at 21:29According to Chet Ramey, shopt -s extdebug
is internally equally to — debugger
. And if bash doesn’t find a debugger during its initialization it unsets this option essentially making my return 1
useless. The above said only happens in non interactive mode since interactive shells can’t be debugged (hence the flags are not unset). And this explains clearly the behaviors stated in my question. So in scripts that should use my trap would need to reset shopt - s extdebug
at the very top.
QUESTION
I'm trying capture the some input regex in Bash but BASH_REMATCH comes EMPTY
...ANSWER
Answered 2017-Mar-31 at 19:34As Cyrus shows in his answer, a simplified version of your code - with the same input - does work on Linux in principle.
That said, your code references capture groups 3
and 4
, whereas your regex only defines 2.
In other words: ${BASH_REMATCH[3]}
and ${BASH_REMATCH[4]}
are empty by definition.
Note, however, that if =~
signals success, BASH_REMATCH
is never fully empty: at the very least - in the absence of any capture groups - ${BASH_REMATCH[0]}
will be defined.
There are some general points worth making:
Your shebang line reads
#!/usr/bin/env /bin/bash
, which is effectively the same as#!/bin/bash
./usr/bin/env
is typically used if you want a version other than/bin/bash
to execute, one you've installed later and put in the PATH (too):
#!/usr/bin/env bash
ghoti points out that another reason for using
#!/usr/bin/env bash
is to also support less common platforms such as FreeBSD, wherebash
, if installed, is located in/usr/local/bin
rather than the usual/bin
.In either scenario it is less predictable which
bash
binary will be executed, because it depends on the effective$PATH
value at the time of invocation.
=~
is one of the few Bash features that are platform-dependent: it uses the particular regex dialect implemented by the platform's regex libraries.\s
is a character class shortcut that is not available on all platforms, notably not on macOS; the POSIX-compliant equivalent is[[:space:]]
.(In your particular case,
\s
should work, however, because your Bash--version
output suggests that you are on a Linux distro.)
It's better not to use all-uppercase shell variable names such as
INPUT
, so as to avoid conflicts with environment variables and special shell variables.
QUESTION
SOLVED: See matzeri's answer below https://stackoverflow.com/a/42611525/4543664
I ran the cygwin64 2.877 setup to update the installation, and there was a new version of bash that was listed for upgrade.
The installation failed with the following error message: The procedure entry point history_lines_read_from_file could not be located in the dynamic link library C:\cygwin64\bin\bash.exe
Post installation setup.log.full shows these errors:
Rebasing with list /var/cache/rebase/rebase_all, built from /var/cache/rebase/rebase_lst /var/cache/rebase/rebase_dyn /var/cache/rebase/rebase_user.
2017/03/02 22:45:16 running: C:\cygwin64\bin\dash.exe "/etc/postinstall/0p_texlive_prep.dash"
2017/03/02 22:45:16 running: C:\cygwin64\bin\dash.exe "/etc/postinstall/0p_update-info-dir.dash"
2017/03/02 22:45:18 running: C:\cygwin64\bin\bash.exe --norc --noprofile "/etc/postinstall/bash.sh"
2017/03/02 22:46:20 abnormal exit: exit code=-1073741511
2017/03/02 22:46:21 running: C:\cygwin64\bin\bash.exe --norc --noprofile "/etc/postinstall/bashdb.sh"
2017/03/02 22:46:23 abnormal exit: exit code=-1073741511
2017/03/02 22:46:23 running: C:\cygwin64\bin\bash.exe --norc --noprofile "/etc/postinstall/ca-certificates.sh"
2017/03/02 22:46:25 abnormal exit: exit code=-1073741511
mintty shortcut flashes open the window and goes down almost immediately.
Any thoughts on how I can fix this?
Update after running cygcheck at Win cmd prompt as admin:
`Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.
C:\WINDOWS\system32>cygcheck /usr/bin/bash.exe
C:\cygwin64\bin\bash.exe
C:\cygwin64\bin\cygwin1.dll
C:\WINDOWS\system32\KERNEL32.dll
C:\WINDOWS\system32\ntdll.dll
C:\WINDOWS\system32\KERNELBASE.dll
C:\WINDOWS\system32\api-ms-win-core-fibers-l2-1-1.dll
C:\cygwin64\bin\cygiconv-2.dll
C:\cygwin64\bin\cygintl-8.dll
C:\cygwin64\bin\cygreadline7.dll
C:\cygwin64\bin\cygncursesw-10.dll
C:\WINDOWS\system32\USER32.dll
C:\WINDOWS\system32\win32u.dll
C:\WINDOWS\system32\GDI32.dll
C:\WINDOWS\system32>`
ANSWER
Answered 2017-Mar-05 at 17:22history_lines_read_from_file
belongs to file cygreadline7.dll
that belongs to package libreadline7
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install BashDB
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page