func loadSavedArgs()

in ops.go [120:154]


func loadSavedArgs() []string {
	res := []string{}
	files, err := os.ReadDir(".")
	if err != nil {
		return res
	}
	r := regexp.MustCompile(`^_.+_$`) // regex to match file names that start and end with '_'
	for _, f := range files {
		if !f.IsDir() && r.MatchString(f.Name()) {
			debug("reading vars from " + f.Name())
			file, err := os.Open(f.Name())
			if err != nil {
				warn("cannot read " + f.Name())
				continue
			}
			scanner := bufio.NewScanner(file)
			r := regexp.MustCompile(`^[a-zA-Z0-9]+=`) // regex to match lines that start with an alphanumeric sequence followed by '='
			for scanner.Scan() {
				line := scanner.Text()
				if r.MatchString(line) {
					debug("found var " + line)
					res = append(res, line)
				}
			}
			err = scanner.Err()
			//nolint:errcheck
			file.Close()
			if err != nil {
				warn(err)
				continue
			}
		}
	}
	return res
}