Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
eepm
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
eepm
Commits
56379277
Commit
56379277
authored
Mar 30, 2023
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eget: improve options parsing
parent
25e445f9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
68 deletions
+62
-68
tools_eget
bin/tools_eget
+62
-68
No files found.
bin/tools_eget
View file @
56379277
...
...
@@ -207,23 +207,22 @@ CURLQ='' #-s
WGETNAMEOPTIONS
=
'--content-disposition'
CURLNAMEOPTIONS
=
'--remote-name --remote-header-name'
LISTONLY
=
''
CHECKURL
=
''
LATEST
=
''
SECONDLATEST
=
''
CHECKMIRRORS
=
''
TARGETFILE
=
''
set_quiet
()
{
WGETQ
=
'-q'
CURLQ
=
'-s'
}
# TODO: parse options in a good way
# TODO:
# -P support
if
[
-z
"
$1
"
]
;
then
echo
"eget - wget like downloader wrapper with wildcard support, uses wget or curl as backend"
>
&2
fatal
"Run
$0
--help to get help"
fi
if
[
"
$1
"
=
"-h"
]
||
[
"
$1
"
=
"--help"
]
;
then
eget_help
()
{
echo
"eget - wget like downloader wrapper with wildcard support in filename part of URL"
echo
"Usage: eget [-q] [-k] [-U] [-O target file] [--list] http://somesite.ru/dir/na*.log"
echo
...
...
@@ -246,71 +245,66 @@ if [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then
echo
"
$
eget --check http://ftp.somesite.ru/test"
echo
"
$
eget --list http://download.somesite.ru 'package-*.tar.xz'"
echo
"
$
eget --list --latest https://github.com/telegramdesktop/tdesktop/releases 'tsetup.*.tar.xz'"
# echo "See $ wget --help for wget options you can use here"
exit
fi
# TODO: passthrou all wget options
if
[
"
$1
"
=
"-q"
]
;
then
set_quiet
shift
fi
if
[
"
$1
"
=
"-k"
]
||
[
"
$1
"
=
"--no-check-certificate"
]
;
then
WGETNOSSLCHECK
=
'--no-check-certificate'
CURLNOSSLCHECK
=
'-k'
shift
fi
if
[
"
$1
"
=
"-U"
]
||
[
"
$1
"
=
"-A"
]
||
[
"
$1
"
=
"--user-agent"
]
;
then
user_agent
=
"Mozilla/5.0 (X11; Linux
$arch
) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36"
WGETUSERAGENT
=
"-U '
$user_agent
'"
CURLUSERAGENT
=
"-A '
$user_agent
'"
shift
fi
LISTONLY
=
''
if
[
"
$1
"
=
"--list"
]
;
then
LISTONLY
=
"
$1
"
set_quiet
shift
fi
}
if
[
"
$1
"
=
"--check"
]
;
then
CHECKURL
=
"
$1
"
shift
fi
LATEST
=
''
if
[
"
$1
"
=
"--latest"
]
;
then
LATEST
=
"
$1
"
shift
if
[
-z
"
$1
"
]
;
then
echo
"eget - wget like downloader wrapper with wildcard support, uses wget or curl as backend"
>
&2
echo
"Run
$0
--help to get help"
>
&2
exit
1
fi
SECONDLATEST
=
''
if
[
"
$1
"
=
"--second-latest"
]
;
then
SECONDLATEST
=
"
$1
"
shift
fi
CHECKMIRRORS
=
''
if
[
"
$1
"
=
"--check-mirrors"
]
;
then
CHECKMIRRORS
=
"
$1
"
while
[
-n
"
$1
"
]
;
do
case
"
$1
"
in
-h
|
--help
)
eget_help
exit
;;
-q
)
set_quiet
;;
-k
|
--no-check-certificate
)
WGETNOSSLCHECK
=
'--no-check-certificate'
CURLNOSSLCHECK
=
'-k'
;;
-U
|
-A
|
--user-agent
)
user_agent
=
"Mozilla/5.0 (X11; Linux
$arch
) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36"
WGETUSERAGENT
=
"-U '
$user_agent
'"
CURLUSERAGENT
=
"-A '
$user_agent
'"
;;
--list
)
LISTONLY
=
"
$1
"
set_quiet
;;
--check
)
CHECKURL
=
"
$1
"
set_quiet
;;
--latest
)
LATEST
=
"
$1
"
;;
--second-latest
)
SECONDLATEST
=
"
$1
"
;;
--check-mirrors
)
CHECKMIRRORS
=
"
$1
"
;;
-O
)
shift
TARGETFILE
=
"
$1
"
;;
-O-
)
TARGETFILE
=
"-"
;;
*
)
break
;;
esac
shift
fi
done
# download to this file
TARGETFILE
=
''
if
[
"
$1
"
=
"-O"
]
;
then
TARGETFILE
=
"
$2
"
shift
2
elif
[
"
$1
"
=
"-O-"
]
;
then
TARGETFILE
=
"-"
shift
1
fi
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment