bonsaiviking / nmap-completion

Bash-completion script for Nmap
68 stars 7 forks source link

Closes issue #1 #4

Open rewanthtammana opened 7 years ago

rewanthtammana commented 7 years ago

In PR #3 , we were parsing a file every time when the user tries to autocomplete --script-args command, it is very ineffective as we have to access the file frequently, the reason why we can't use this approach is well explained in PR #3 . I developed a new code which doesn't waste its time on I/O operations and instead the new code is directly connected to the kernel.

Working of my code

The script-args.db file is a db file which contains all the available --script-args options along with script-name.

Let me illustrate this with an example. Assume there are only two lines in the script-args.db file

$ cat script-args.db
acarsd-info: acarsd-info.timeout acarsd-info.bytes
ajp-auth: ajp-auth.path
Format of the script-args file is as follows,
<scriptname>: <arg1> <arg2> <arg3> ....

On executing the script.sh file, it extracts the script-name and the available options for every script. So the directory structure would be something like this,

|- acarsd-info/
    |- acarsd-info.timeout
    |- acarsd-info.bytes
|- ajp-auth/
    |- ajp-auth.path

So, here I'm using the name of the files to autocomplete --script-args . This is a way faster than the previous method as there are no I/O operations involved and it is directly associated with the kernel itself.