func (script *Script) Alias(client *docker.Client) (*posix.Cmd, error) {
	if err := script.Write(client); err != nil {
		return nil, err
	}
	targetPath := filepath.Join(context.ExportPath(), script.spec.Path.Base())
	return posix.Alias(script.spec.Path.Base(), targetPath), nil
}
Alias returns the command of alias.
package script
import (
	"bufio"
	"fmt"
	"os"
	"path"
	"path/filepath"
	"regexp"
	"strings"
	"syscall"
	"time"
	"github.com/k-kinzal/aliases/pkg/logger"
	"github.com/k-kinzal/aliases/pkg/posix"
	"github.com/k-kinzal/aliases/pkg/util"
	"github.com/k-kinzal/aliases/pkg/aliases/context"
	"github.com/k-kinzal/aliases/pkg/aliases/yaml"
	"github.com/k-kinzal/aliases/pkg/docker"
)
type Script struct {
	spec yaml.Option
}
func (script *Script) Write(client *docker.Client) error {
	return script.WriteWithOverride(client, nil, docker.RunOption{})
}
func (script *Script) WriteWithOverride(client *docker.Client, overrideArgs []string, overrideOption docker.RunOption) error {
	targetPath := filepath.Join(context.ExportPath(), script.spec.Namespace(), script.spec.Path.Base())
	if err := os.MkdirAll(path.Dir(targetPath), 0755); err != nil {
		return err
	}
	fp, err := os.OpenFile(targetPath, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0755)
	if err != nil {
		return nil
	}
	defer fp.Close()
	shell := adaptShell(script.spec)
	cmd, err := shell.Command(client, overrideArgs, overrideOption, false)
	if err != nil {
		return err
	}
	if _, err := fp.WriteString(fmt.Sprintf("#!/bin/sh\n%s", cmd.String())); err != nil {
		return err
	}
	return nil
}