mirror of
https://github.com/bettercap/bettercap
synced 2025-07-06 04:52:10 -07:00
fix: caplet code is loaded entirely and comments are only skipped while evaluating it
This commit is contained in:
parent
bf8a7659b5
commit
08d85251dd
2 changed files with 4 additions and 3 deletions
|
@ -44,6 +44,10 @@ func (cap *Caplet) Eval(argv []string, lineCb func(line string) error) error {
|
|||
// temporarily change the working directory
|
||||
return fs.Chdir(filepath.Dir(cap.Path), func() error {
|
||||
for _, line := range cap.Code {
|
||||
// skip empty lines and comments
|
||||
if line == "" || line[0] == '#' {
|
||||
continue
|
||||
}
|
||||
// replace $0 with argv[0], $1 with argv[1] and so on
|
||||
for i, arg := range argv {
|
||||
what := fmt.Sprintf("$%d", i)
|
||||
|
|
|
@ -79,9 +79,6 @@ func Load(name string) (error, *Caplet) {
|
|||
return fmt.Errorf("error reading caplet %s: %v", fileName, err), nil
|
||||
} else {
|
||||
for line := range reader {
|
||||
if line == "" || line[0] == '#' {
|
||||
continue
|
||||
}
|
||||
cap.Code = append(cap.Code, line)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue