Skip to content

Commit 07424cb

Browse files
author
ggtrd
committed
fix subcommand list
1 parent 325debc commit 07424cb

File tree

1 file changed

+60
-19
lines changed

1 file changed

+60
-19
lines changed

bashpack.sh

Lines changed: 60 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,16 +1499,16 @@ sourceslist_install_structure() {
14991499
subcommand_list() {
15001500

15011501
local list_tmp="$dir_tmp/$NAME_LOWERCASE-commands-list"
1502-
local list_installed_tmp="$dir_tmp/$NAME_LOWERCASE-commands-installed"
1502+
# local list_installed_tmp="$dir_tmp/$NAME_LOWERCASE-commands-installed"
15031503

15041504
local installed="[installed]"
15051505
local updatable="[update available]"
15061506

15071507

1508-
# Detect installed subcommands
1509-
if [ -d "$dir_commands" ] && [ ! -z "$(ls $dir_commands)" ]; then
1510-
ls $dir_commands >> $list_installed_tmp
1511-
fi
1508+
# # Detect installed subcommands
1509+
# if [ -d "$dir_commands" ] && [ ! -z "$(ls $dir_commands)" ]; then
1510+
# ls $dir_commands > $list_installed_tmp
1511+
# fi
15121512

15131513

15141514
# If "local" is not precised in arguments, then it means that we want to list remotes command too
@@ -1585,7 +1585,6 @@ subcommand_list() {
15851585
| sed '/\/.*/d' \
15861586
| sed '/^\(?.=\).*/d' \
15871587
| grep -iw "\.$subcommands_allowed_extensions" \
1588-
| sed "s/\.[$subcommands_allowed_extensions]*//" \
15891588
| sed "s|$| $real_url $checksum|" \
15901589
| sort -u >> $file_registry
15911590
done < $list_tmp
@@ -1606,10 +1605,10 @@ subcommand_list() {
16061605
done
16071606

16081607

1609-
# Detect remotes subcommands
1610-
if [ -f "$file_registry" ]; then
1611-
cat $file_registry | sed 's/ .*//' >> $list_installed_tmp
1612-
fi
1608+
# # Detect remotes subcommands
1609+
# if [ -f "$file_registry" ]; then
1610+
# cat $file_registry | sed 's/ .*//' >> $list_installed_tmp
1611+
# fi
16131612

16141613
else
16151614
log_error "'$file_sourceslist_subcommands' is empty."
@@ -1625,39 +1624,81 @@ subcommand_list() {
16251624
# If "refresh-only" is precised in arguments, then it means that we only want to refresh the registry and not display the list
16261625
if [ "$1" != "refresh-only" ]; then
16271626

1627+
16281628
# Finally display all the subcommands and specify if already installed
1629-
if [ -f "$list_installed_tmp" ] && [ -s "$list_installed_tmp" ]; then
1629+
if [ -f "$file_registry" ] && [ -s "$file_registry" ]; then
16301630

16311631
log_info "reading registry."
16321632

1633-
while read -r command; do
1634-
if [ "$command" != "" ]; then
1633+
while read -r line; do
1634+
if [ "$line" != "" ]; then
1635+
1636+
# local command_formatted="$(echo $line | sed 's/\.\(.*\)/ [\1]/')"
1637+
local command_formatted="$(echo $line | sed 's|\.\(.*\) http.*| [\1]|')"
1638+
# local command_formatted="$(echo $line | sed 's| .*||' | sed 's|\(.*\)\.\(.*\)|[\2] \1|')"
1639+
# local command_formatted=$command
16351640

1636-
local command_formatted="$(echo $command | sed 's/\.\(.*\)/ [\1]/')"
1641+
local command_file="$(echo $line | sed 's| .*||')"
16371642

16381643
# Checking if the subcommand is already installed
1639-
if [ -f "$dir_commands/$command" ]; then
1644+
if [ -f "$dir_commands/$command_file" ]; then
16401645

1641-
local command_checksum_known="$(file_checksum "$dir_commands/$command")"
1642-
local command_checksum_remote="$(file_checksum $(get_config_value $file_registry $command 2))"
1646+
local command_checksum_known="$(file_checksum "$dir_commands/$command_file")"
1647+
local command_checksum_remote="$(file_checksum $(get_config_value $file_registry $command_file 2))"
16431648

16441649
if [ "$command_checksum_known" = "$command_checksum_remote" ]; then
16451650
echo "$command_formatted $installed"
16461651
else
16471652
echo "$command_formatted $installed $updatable"
16481653
fi
1654+
16491655
else
16501656
echo "$command_formatted"
16511657
fi
16521658

16531659

16541660
fi
1655-
done < $list_installed_tmp | sort -ud
1661+
done < $file_registry | sort -ud
16561662

16571663
# rm -f $list_installed_tmp
16581664
else
1659-
log_error "no command installed."
1665+
log_error "no command found."
16601666
fi
1667+
1668+
1669+
# # Finally display all the subcommands and specify if already installed
1670+
# if [ -f "$list_installed_tmp" ] && [ -s "$list_installed_tmp" ]; then
1671+
1672+
# log_info "reading registry."
1673+
1674+
# while read -r command; do
1675+
# if [ "$command" != "" ]; then
1676+
1677+
# local command_formatted="$(echo $command | sed 's/\.\(.*\)/ [\1]/')"
1678+
1679+
# # Checking if the subcommand is already installed
1680+
# if [ -f "$dir_commands/$command" ]; then
1681+
1682+
# local command_checksum_known="$(file_checksum "$dir_commands/$command")"
1683+
# local command_checksum_remote="$(file_checksum $(get_config_value $file_registry $command 2))"
1684+
1685+
# if [ "$command_checksum_known" = "$command_checksum_remote" ]; then
1686+
# echo "$command_formatted $installed"
1687+
# else
1688+
# echo "$command_formatted $installed $updatable"
1689+
# fi
1690+
# else
1691+
# echo "$command_formatted"
1692+
# fi
1693+
1694+
1695+
# fi
1696+
# done < $list_installed_tmp | sort -d
1697+
1698+
# # rm -f $list_installed_tmp
1699+
# else
1700+
# log_error "no command installed."
1701+
# fi
16611702
fi
16621703

16631704
}

0 commit comments

Comments
 (0)