From cb61b6f101ffe93557a9e7da37d12015f4e4fd54 Mon Sep 17 00:00:00 2001 From: mateuscomh Date: Sat, 1 Feb 2025 12:21:36 -0300 Subject: [PATCH] fix: WSL2 compatibility and warning if xclip no exist --- README.md | 2 +- shellPass.sh | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 60ee830..c33806b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # shellPass - Shell Script Password Generator -[![Release](https://img.shields.io/badge/release-3.3.1-brightgreen)](https://github.com/mateuscomh/shellPass/releases) +[![Release](https://img.shields.io/badge/release-3.4.1-brightgreen)](https://github.com/mateuscomh/shellPass/releases) [![Build Status](https://github.com/mateuscomh/shellPass/actions/workflows/super-linter.yml/badge.svg)](https://github.com/mateuscomh/shellPass/actions/workflows/super-linter.yml) ## Overview diff --git a/shellPass.sh b/shellPass.sh index 78f57a0..7c5c918 100755 --- a/shellPass.sh +++ b/shellPass.sh @@ -4,7 +4,7 @@ export LANG=C #----------------------------------------------------| # Matheus Martins 3mhenrique@gmail.com # https://github.com/mateuscomh/yoURL -# 30/03/2021 3.2.0 GPL3 +# 30/03/2021 3.4.1 GPL3 # Generate secure passwords on terminal # Depends: xclip on GNU/Linux / pbcopy on IOS #----------------------------------------------------| @@ -14,7 +14,7 @@ BOLD=$(tput bold) ITALIC=$(tput dim) main() { - local VERSION="Ver:3.3.1" + local VERSION="Ver:3.4.1" local AUTHOR="Matheus Martins-3mhenrique@gmail.com" local USAGE="Generate random passwords from CLI ███████╗██╗ ██╗███████╗██╗ ██╗ ██████╗ █████╗ ▄▄███▄▄·▄▄███▄▄· @@ -83,11 +83,19 @@ _writeinfile() { } _makePass() { - # PASS=$(cat /dev/urandom LC_ALL=C | tr -dc "$CPX" | head -c "$MAX") PASS=$(tr -dc "$CPX" /dev/null ;; - Linux) command -v xclip >/dev/null && { printf %s "$PASS" | xclip -sel copy; } ;; + Linux) + if grep -iq Microsoft /proc/version; then + printf "%s" "$PASS" | clip.exe + elif command -v xxclip >/dev/null; then + printf "%s" "$PASS" | xclip -sel clip + else + echo "$PASS" + exit 1 + fi + ;; *) echo "This is compatible only for GNU/Linux, MacOS or WSL2" exit 1