mirror of
https://github.com/dvorka/hstr.git
synced 2024-12-25 08:55:09 +08:00
Adding --is-tiocsti parameter (injects in prompt, which is undesired), updating year to 2023, removing WIP defines for TIOCSTI debugging #478
This commit is contained in:
parent
83560c473b
commit
451758c0c1
66 changed files with 199 additions and 99 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -12,6 +12,7 @@
|
|||
/src/hstr
|
||||
/src/hh
|
||||
.deps/
|
||||
.vscode
|
||||
Makefile
|
||||
Makefile.in
|
||||
*.o
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2023-03-19 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
|
||||
* Released v2.7.0 - important fix release ensuring that HSTR will work
|
||||
on operating systems and Linux kernels without TIOCSTI support.
|
||||
|
||||
2022-12-11 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
|
||||
* Released v2.6.0 - fix release (several memory leak and overflow fixes,
|
||||
|
|
2
PKGBUILD
2
PKGBUILD
|
@ -4,7 +4,7 @@
|
|||
# Contributor: Busindre <busilezas at busindre.com>
|
||||
|
||||
pkgname=hstr
|
||||
pkgver=2.6
|
||||
pkgver=2.7
|
||||
pkgrel=1
|
||||
pkgdesc="A command line utility that brings improved BASH command completion from the history. It aims to make completion easier and more efficient than Ctrl-r."
|
||||
arch=('x86_64'
|
||||
|
|
17
SECURITY.md
17
SECURITY.md
|
@ -4,18 +4,19 @@
|
|||
|
||||
The following HSTR versions are currently being supported with security updates.
|
||||
|
||||
| Version | Supported |
|
||||
| ------- | ------------------ |
|
||||
| 2.6.0 | :white_check_mark: |
|
||||
| 2.5.0 | :white_check_mark: |
|
||||
| 2.4.0 | :white_check_mark: |
|
||||
| <= 2.3.0 | :x: |
|
||||
| Version | Supported |
|
||||
| -------- | ------------------ |
|
||||
| 2.7.0 | :white_check_mark: |
|
||||
| 2.6.0 | :white_check_mark: |
|
||||
| 2.5.0 | :white_check_mark: |
|
||||
| 2.4.0 | :white_check_mark: |
|
||||
| <= 2.3.0 | :x: |
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
Please report HSTR vulnerabilities to
|
||||
Please report HSTR vulnerabilities to
|
||||
[martin.dvorak@mindforger.com](martin.dvorak@mindforger.com)
|
||||
|
||||
All reported vulnerabilities will be examined, reproduced and
|
||||
expected fix release and release date will be shared with
|
||||
expected fix release and release date will be shared with
|
||||
the reporter.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
# Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
# Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
# Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
# Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2016-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
# Copyright (C) 2016-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
# Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -147,8 +147,8 @@ then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
export ARG_BAZAAR_MSG="HSTR 2.6.0"
|
||||
export ARG_VERSION="2.6.0"
|
||||
export ARG_BAZAAR_MSG="HSTR 2.7.0"
|
||||
export ARG_VERSION="2.7.0"
|
||||
|
||||
# Debian releases: https://www.debian.org/releases/
|
||||
# 6/7/8/9/10: squeeze wheezy jessie stretch buster
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
# Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
# Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -20,7 +20,7 @@
|
|||
# This script is available from http://www.mindforger.com/fedora/fedora-rpm-from-deb.sh
|
||||
# to be easily available in VMs
|
||||
|
||||
export MFVERSION="2.6.0"
|
||||
export MFVERSION="2.7.0"
|
||||
export MFPRJNAME="hstr-${MFVERSION}"
|
||||
export AMD64NAME="hstr_${MFVERSION}-1_amd64"
|
||||
export I386NAME="hstr_${MFVERSION}-1_i386"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
# Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
# Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -20,7 +20,7 @@
|
|||
|
||||
export SCRIPT_HOME=`pwd`
|
||||
|
||||
export HSTR_VERSION="2.6.0"
|
||||
export HSTR_VERSION="2.7.0"
|
||||
|
||||
export NOW=`date +%Y-%m-%d--%H-%M-%S`
|
||||
export GH_RELEASE_DIR=~/p/hstr/release
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
# Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
# Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
# Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
# Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
# Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
# Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
# Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
# Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# .travis.yml Travis CI configuration file for HSTR
|
||||
#
|
||||
# Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
# Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
# Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
# Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -163,8 +163,8 @@ then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
export ARG_BAZAAR_MSG="Release 2.6"
|
||||
export ARG_MAJOR_VERSION=2.6.
|
||||
export ARG_BAZAAR_MSG="Release 2.7"
|
||||
export ARG_MAJOR_VERSION=2.7.
|
||||
export ARG_MINOR_VERSION=1 # minor version is incremented for every Ubuntu version
|
||||
|
||||
# https://wiki.ubuntu.com/Releases
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
# Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
# Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# configure.ac Autoconf configuration file
|
||||
#
|
||||
# Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
# Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -20,7 +20,7 @@
|
|||
|
||||
AC_PREREQ([2.69])
|
||||
|
||||
AC_INIT(hstr, 2.6.0, martin.dvorak@mindforger.com)
|
||||
AC_INIT(hstr, 2.7.0, martin.dvorak@mindforger.com)
|
||||
AC_CONFIG_FILES([Makefile src/Makefile man/Makefile])
|
||||
|
||||
# Check src dir existence.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
# Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
|
7
hstr.pro
7
hstr.pro
|
@ -1,6 +1,6 @@
|
|||
# hstr.pro Qt project file for HSTR shell history compleation utility
|
||||
# hstr.pro Qt project file for HSTR shell history completion utility
|
||||
#
|
||||
# Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
# Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -61,6 +61,7 @@ hstrdebug {
|
|||
}
|
||||
QMAKE_LINK = gcc
|
||||
|
||||
DEFINES += LINUX_KERNEL_6
|
||||
# TIOCSTI debugging:
|
||||
# DEFINES += __CYGWIN__
|
||||
|
||||
message(DEFINES of hstr.pro build: $$DEFINES)
|
||||
|
|
10
pad.xml
10
pad.xml
|
@ -2,7 +2,7 @@
|
|||
<!--
|
||||
pad.xml PAD file for HSTR
|
||||
|
||||
Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -51,10 +51,10 @@
|
|||
</Company_Info>
|
||||
<Program_Info>
|
||||
<Program_Name>HSTR</Program_Name>
|
||||
<Program_Version>2.6.0</Program_Version>
|
||||
<Program_Release_Month>12</Program_Release_Month>
|
||||
<Program_Release_Day>10</Program_Release_Day>
|
||||
<Program_Release_Year>2022</Program_Release_Year>
|
||||
<Program_Version>2.7.0</Program_Version>
|
||||
<Program_Release_Month>3</Program_Release_Month>
|
||||
<Program_Release_Day>19</Program_Release_Day>
|
||||
<Program_Release_Year>2023</Program_Release_Year>
|
||||
<Program_Cost_Dollars />
|
||||
<Program_Cost_Other_Code>USD</Program_Cost_Other_Code>
|
||||
<Program_Cost_Other />
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# snapcraft.yaml snap builder configuration
|
||||
#
|
||||
# Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
# Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
hashset.c hash set implementation
|
||||
|
||||
Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
23
src/hstr.c
23
src/hstr.c
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
hstr.c HSTR shell history completion utility
|
||||
|
||||
Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -137,7 +137,7 @@
|
|||
|
||||
// major.minor.revision
|
||||
static const char* VERSION_STRING=
|
||||
"hstr version \"2.7.0\" (2023-03-11T18:15:00)"
|
||||
"hstr version \"2.7.0\" (2023-03-19T18:15:00)"
|
||||
"\n";
|
||||
|
||||
static const char* HSTR_VIEW_LABELS[]={
|
||||
|
@ -190,7 +190,7 @@ static const char* INSTALL_BASH_STRING=
|
|||
"\n READLINE_POINT=${#READLINE_LINE}"
|
||||
"\n}"
|
||||
"\nif [[ $- =~ .*i.* ]]; then bind -x '\"\\C-r\": \"hstrwsl\"'; fi"
|
||||
#elif defined(__CYGWIN__) || defined(LINUX_KERNEL_6)
|
||||
#elif defined(__CYGWIN__)
|
||||
"\nfunction hstrcygwin {"
|
||||
"\n offset=${READLINE_POINT}"
|
||||
"\n READLINE_POINT=0"
|
||||
|
@ -263,6 +263,7 @@ static const char* HELP_STRING=
|
|||
"\n --show-configuration -s ... show configuration to be added to ~/.bashrc"
|
||||
"\n --show-zsh-configuration -z ... show zsh configuration to be added to ~/.zshrc"
|
||||
"\n --show-blacklist -b ... show commands to skip on history indexation"
|
||||
"\n --is-tiocsti -t ... detect whether TIOCSTI is supported and print y or n"
|
||||
"\n --insert-in-terminal=[c] -i ... insert command c in terminal prompt and exit"
|
||||
"\n --version -V ... show version details"
|
||||
"\n --help -h ... help"
|
||||
|
@ -288,6 +289,7 @@ static const struct option long_options[] = {
|
|||
{"show-configuration", GETOPT_NO_ARGUMENT, NULL, 's'},
|
||||
{"show-zsh-configuration", GETOPT_NO_ARGUMENT, NULL, 'z'},
|
||||
{"show-blacklist", GETOPT_NO_ARGUMENT, NULL, 'b'},
|
||||
{"is-tiocsti", GETOPT_NO_ARGUMENT, NULL, 't'},
|
||||
{"insert-in-terminal", GETOPT_REQUIRED_ARGUMENT, NULL, 'i'},
|
||||
{0, 0, NULL, 0 }
|
||||
};
|
||||
|
@ -1670,7 +1672,7 @@ void hstr_interactive(void)
|
|||
void hstr_getopt(int argc, char **argv)
|
||||
{
|
||||
int option_index = 0;
|
||||
int option = getopt_long(argc, argv, "fkVhnszbi", long_options, &option_index);
|
||||
int option = getopt_long(argc, argv, "fkVhnszbti", long_options, &option_index);
|
||||
if(option != -1) {
|
||||
switch(option) {
|
||||
case 'f':
|
||||
|
@ -1700,6 +1702,14 @@ void hstr_getopt(int argc, char **argv)
|
|||
printf("%s", VERSION_STRING);
|
||||
hstr_exit(EXIT_SUCCESS);
|
||||
break;
|
||||
case 't':
|
||||
if(is_tiocsti) {
|
||||
printf("y");
|
||||
} else {
|
||||
printf("n");
|
||||
}
|
||||
hstr_exit(EXIT_SUCCESS);
|
||||
break;
|
||||
case 'h':
|
||||
printf("%s", HELP_STRING);
|
||||
hstr_exit(EXIT_SUCCESS);
|
||||
|
@ -1710,7 +1720,7 @@ void hstr_getopt(int argc, char **argv)
|
|||
break;
|
||||
case 's':
|
||||
// ZSH_VERSION is not exported by zsh > detected by parent process name
|
||||
if(isZshParentShell()) {
|
||||
if(is_zsh_parent_shell()) {
|
||||
printf("%s", INSTALL_ZSH_STRING);
|
||||
} else {
|
||||
printf("%s", INSTALL_BASH_STRING);
|
||||
|
@ -1733,6 +1743,9 @@ int hstr_main(int argc, char* argv[])
|
|||
{
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
// initialize global TIOCSTI indicator
|
||||
is_tiocsti = is_tiocsti_supported();
|
||||
|
||||
hstr=malloc(sizeof(Hstr));
|
||||
hstr_init();
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
hstr_blacklist.c commands to be skipped from history
|
||||
|
||||
Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
hstr_curses.c Curses utilities
|
||||
http://pueblo.sourceforge.net/doc/manual/ansi_color_codes.html
|
||||
|
||||
Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
hstr_favorites.c favorite commands
|
||||
|
||||
Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
hstr_history.c loading and processing of BASH history
|
||||
|
||||
Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -49,7 +49,7 @@ char* get_history_file_name(void)
|
|||
{
|
||||
char* historyFile = getenv(ENV_VAR_HISTFILE);
|
||||
if(!historyFile || strlen(historyFile)==0) {
|
||||
if(isZshParentShell()) {
|
||||
if(is_zsh_parent_shell()) {
|
||||
historyFile = get_home_file_path(FILE_ZSH_HISTORY);
|
||||
if(access(historyFile, F_OK) == -1) {
|
||||
free(historyFile);
|
||||
|
@ -104,7 +104,7 @@ char* parse_history_line(char *l)
|
|||
#ifndef HSTR_TESTS_UNIT
|
||||
static bool isZsh, c;
|
||||
if(!c) {
|
||||
isZsh=isZshParentShell();
|
||||
isZsh=is_zsh_parent_shell();
|
||||
c=true;
|
||||
}
|
||||
#endif
|
||||
|
@ -405,7 +405,7 @@ int history_mgmt_remove_from_ranked(char *cmd, HistoryItems *history) {
|
|||
|
||||
void history_mgmt_flush(void)
|
||||
{
|
||||
if(dirty && !isZshParentShell()) {
|
||||
if(dirty && !is_zsh_parent_shell()) {
|
||||
fill_terminal_input("history -r\n", false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
hstr_regexp.c simplified regexp that suits HSTR needs - matching and caching
|
||||
|
||||
Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
hstr_utils.c utilities
|
||||
|
||||
Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -23,10 +23,15 @@
|
|||
// TODO PID_BUFFER 20+ characters might be enough
|
||||
#define PID_BUFFER_SIZE 128
|
||||
|
||||
// This define is used to compile out code which inserts command to console - thus
|
||||
// define allows to activate and debug shell script workaround that is used on WSL
|
||||
// and Cygwin.
|
||||
//#define DEBUG_NO_TIOCSTI
|
||||
/*
|
||||
* global variables
|
||||
*/
|
||||
|
||||
bool is_tiocsti = false;
|
||||
|
||||
/*
|
||||
* functions
|
||||
*/
|
||||
|
||||
// strdup() not in ISO C
|
||||
char* hstr_strdup(const char* s)
|
||||
|
@ -106,7 +111,38 @@ void hstr_chop(char *s)
|
|||
}
|
||||
}
|
||||
|
||||
#if !defined(__MS_WSL__) && !defined(__CYGWIN__) && !defined(LINUX_KERNEL_6) && !defined(DEBUG_NO_TIOCSTI)
|
||||
bool is_tiocsti_supported()
|
||||
{
|
||||
#if defined(__MS_WSL__) || defined(__CYGWIN__)
|
||||
return false;
|
||||
#else
|
||||
|
||||
int fd;
|
||||
struct termios t;
|
||||
|
||||
fd = open("/dev/tty", O_RDWR);
|
||||
if (fd < 0) {
|
||||
perror("open /dev/tty");
|
||||
printf("Error: unable to detect whether TIOCSTI is supported by the kernel");
|
||||
return false;
|
||||
}
|
||||
if (tcgetattr(fd, &t) < 0) {
|
||||
perror("tcgetattr");
|
||||
printf("Error: unable to detect whether TIOCSTI is supported by the kernel");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool is_supported = false;
|
||||
if (!ioctl(fd, TIOCSTI, "a")) {
|
||||
return true;
|
||||
}
|
||||
close(fd);
|
||||
|
||||
return is_supported;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(__MS_WSL__) && !defined(__CYGWIN__)
|
||||
void tiocsti()
|
||||
{
|
||||
char buf[] = DEFAULT_COMMAND;
|
||||
|
@ -120,7 +156,7 @@ void tiocsti()
|
|||
void fill_terminal_input(char* cmd, bool padding)
|
||||
{
|
||||
if(cmd && strlen(cmd)>0) {
|
||||
#if defined(__MS_WSL__) || defined(__CYGWIN__) || defined(LINUX_KERNEL_6) || defined(DEBUG_NO_TIOCSTI)
|
||||
#if defined(__MS_WSL__) || defined(__CYGWIN__)
|
||||
fprintf(stderr, "%s", cmd);
|
||||
if(padding) fprintf(stderr, "%s", "\n");
|
||||
#else
|
||||
|
@ -227,7 +263,7 @@ char *get_shell_name_by_ppid(const int pid)
|
|||
return name;
|
||||
}
|
||||
|
||||
bool isZshParentShell(void) {
|
||||
bool is_zsh_parent_shell(void) {
|
||||
pid_t parentPid=getppid();
|
||||
char* cmdline=get_shell_name_by_ppid(parentPid);
|
||||
bool result=cmdline && strstr(cmdline, "zsh");
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
hashset.h header file for hash set
|
||||
|
||||
Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
hstr.h header file for HSTR shell history completion utility
|
||||
|
||||
Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
hstr_blacklist.h header file for commands to be skipped from history
|
||||
|
||||
Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
hstr_curses.h header file for curses helpers
|
||||
|
||||
Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
hstr_favorites.h header file for favorite commands
|
||||
|
||||
Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
hstr_history.h header file for loading and processing of BASH history
|
||||
|
||||
Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
hstr_regexp.h header file for simplified regexp that suits HSTR needs
|
||||
|
||||
Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
hstr_utils.h header file for HSTR utilities
|
||||
|
||||
Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -20,12 +20,14 @@
|
|||
#define HSTR_UTILS_H
|
||||
|
||||
#include <ctype.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define ENV_VAR_HOME "HOME"
|
||||
|
@ -36,10 +38,51 @@
|
|||
#define MIN(a,b) (((a)<(b))?(a):(b))
|
||||
#define MAX(a,b) (((a)>(b))?(a):(b))
|
||||
|
||||
// TIOCSTI is an acronym for "Terminal Input Output Control STack Input",
|
||||
// and it is a system call used in Unix-like operating systems.
|
||||
// The TIOCSTI system call allows to insert data into the input buffer
|
||||
// of a terminal as if it had been typed by the user.
|
||||
//
|
||||
// TIOCSTI is NOT available on:
|
||||
// - Linux kernel >=6.2.0
|
||||
// - Cygwin
|
||||
// - WSL
|
||||
//
|
||||
// HSTR uses TIOCSTI to insert a command chosen by the user in HSTR
|
||||
// to shell prompt.
|
||||
//
|
||||
// HSTR run:
|
||||
//
|
||||
// - user runs `hstr` command
|
||||
// - `hstr` checks whther TIOCSTI is supported by the kernel or not
|
||||
// - if SUPPORTED, then HSTR continues as it will be able to insert
|
||||
// any chosen command into bash prompt
|
||||
// - if NOT supported, then:
|
||||
// - HSTR checks for HSTR_TIOCSTI environment variable:
|
||||
// - if it is NOT defined, then it prints error and asks
|
||||
// user to configure HSTR (--show-configuration >> .*rc)
|
||||
// - if it is DEFINED, then:
|
||||
// - if it is SET to `n`, then HSTR presumes that it has
|
||||
// been configured (shell function is defined) and continues > DONE
|
||||
// - OTHERWISE it prints error and ask user to configure HSTR
|
||||
//
|
||||
// HSTR features related to TIOCSTI
|
||||
//
|
||||
// - HSTR can detect whether TIOCSTI is supported by the kernel:
|
||||
// hstr --is-tiocsti
|
||||
// the command returns "y" or "n" (and exit code: 0 or 1)
|
||||
// - HSTR checks for the following env variable if TIOCSTI is not detected
|
||||
// HSTR_TIOCSTI=y or HSTR_TIOCSTI=n
|
||||
//
|
||||
|
||||
// global TIOCSTI indicator declaration
|
||||
extern bool is_tiocsti;
|
||||
|
||||
char* hstr_strdup(const char* s);
|
||||
int hstr_strlen(const char* s);
|
||||
char* hstr_strelide(char* buffer, const char* s, unsigned maxlength);
|
||||
void hstr_chop(char* s);
|
||||
bool is_tiocsti_supported();
|
||||
#ifndef __CYGWIN__
|
||||
void tiocsti();
|
||||
#endif
|
||||
|
@ -48,7 +91,7 @@ void reverse_char_pointer_array(char** array, unsigned length);
|
|||
void get_hostname(int bufferSize, char* buffer);
|
||||
char* get_home_file_path(char* filename);
|
||||
void toggle_case(char* str, bool lowercase);
|
||||
bool isZshParentShell(void);
|
||||
bool is_zsh_parent_shell(void);
|
||||
char* zsh_unmetafy(char* s, int* len);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
radixsort.h header file for radix sort implementation
|
||||
|
||||
Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
main.c HSTR shell history completion utility main
|
||||
|
||||
Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
radixsort.c radix sort
|
||||
|
||||
Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# hstr-unit-tests.pro Qt project file of UNIT tests for HSTR
|
||||
#
|
||||
# Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
# Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
test.c UNIT tests main for HSTR shell history completion utility
|
||||
|
||||
Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
test_*.c HSTR test
|
||||
|
||||
Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
test_*.c HSTR test
|
||||
|
||||
Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
test_*.c HSTR test
|
||||
|
||||
Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
test_*.c HSTR test
|
||||
|
||||
Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
# Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
# Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
# Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
# Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
# Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
# Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
# Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
# Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2014-2022 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
# Copyright (C) 2014-2023 Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
|
Loading…
Reference in a new issue