Skip to content

Commit eb7e869

Browse files
authored
Merge pull request #793 from ivan-hc/dev
Add "$REALDIR" variable to "APP-MANAGER" and "install.am" to keep the shell in the current directory
2 parents e40966a + a986294 commit eb7e869

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

APP-MANAGER

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#!/usr/bin/env bash
22

3-
AMVERSION="7.2"
3+
AMVERSION="7.2.1"
44

55
# Determine main repository and branch
66
AMREPO="https://raw.githubusercontent.com/ivan-hc/AM/main"
77
AMBRANCH=$(basename "$AMREPO")
88

99
# Determine the name of this script and its working directory
10+
export REALDIR="$PWD"
1011
DIR="$( cd "$( dirname "$0" )" && pwd )"
1112
CLI=$(basename "$0")
1213

modules/install.am

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ function _ending_the_installation() {
9393
$AMCLIPATH -R "$LATESTDIR" 1> /dev/null
9494
else
9595
chown -R $currentuser "$AMCACHEDIR"/about 2> /dev/null
96-
for metapackage in $(echo "$METAPACKAGES"); do
96+
for metapackage in $METAPACKAGES; do
9797
if grep -q "$metapackage" ./"$arg" 2> /dev/null; then
9898
metascript=$(ls -td "$APPSPATH"/* | head -1 | sed 's:.*/::')
9999
fi
@@ -106,7 +106,7 @@ function _ending_the_installation() {
106106
fi
107107
$SUDOCOMMAND rm "$AMCACHEDIR"/"$arg"
108108
_check_version
109-
app_version=$(cat "$AMCACHEDIR"/version-args | grep -w "$LATESTDIR |" | sed 's:.*| ::')
109+
app_version=$(grep -w "$LATESTDIR |" 0<"$AMCACHEDIR"/version-args | sed 's:.*| ::')
110110
echo "$LATESTDIR $app_version" >> "$AMCACHEDIR"/installed
111111
fi
112112
else
@@ -217,7 +217,7 @@ function _install_arg() {
217217

218218
# This function is for local installation scripts
219219
function _install_local_script() {
220-
path2arg=$(echo "$arg")
220+
path2arg="$arg"
221221
arg=$(echo "$path2arg" | sed 's:.*/::')
222222
mkdir -p "$AMCACHEDIR"/tmp && rm -f "$AMCACHEDIR"/tmp/* &&
223223
cp "$path2arg" "$AMCACHEDIR"/tmp/"$arg" &&
@@ -336,6 +336,7 @@ while [ -n "$1" ]; do
336336
echo "____________________________________________________________________________"
337337
;;
338338
*)
339+
cd "$REALDIR" || return
339340
# If the "tmp" directory is not removed, the installation failed, so remove the app
340341
if test -d "$APPSPATH"/"$arg"/tmp; then
341342
$SUDOCOMMAND "$APPSPATH"/"$arg"/remove 2> /dev/null
@@ -344,8 +345,12 @@ while [ -n "$1" ]; do
344345
if test -f "$APPSPATH"/"$arg"/remove; then
345346
echo "\"$arg\" is already installed!" | tr '[:lower:]' '[:upper:]'
346347
else
347-
if test -f "$arg" 2> /dev/null; then
348-
_install_local_script
348+
if echo "$arg" | grep -q "/"; then
349+
if test -f "$arg" 2> /dev/null; then
350+
_install_local_script
351+
else
352+
echo " 💀 ERROR: the file \"$arg\" does NOT exist"
353+
fi
349354
elif test -f "$AMPATH/neodb"; then
350355
_install_from_third_party_repo
351356
elif curl --output /dev/null --silent --head --fail "$APPSDB"/"$arg" 1>/dev/null; then

0 commit comments

Comments
 (0)