push golang regex with broken if statement
This commit is contained in:
parent
c1b7279d31
commit
c8711cf1fa
@ -5,6 +5,9 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
|
"log"
|
||||||
|
"bytes"
|
||||||
|
"regexp"
|
||||||
|
|
||||||
"pikman/alpine"
|
"pikman/alpine"
|
||||||
"pikman/arch"
|
"pikman/arch"
|
||||||
@ -77,16 +80,21 @@ func (c *Command) processCommand() error {
|
|||||||
var err error
|
var err error
|
||||||
|
|
||||||
if c.OsType != types.Ubuntu && c.OsType != types.Flatpak && c.Command != "init" && c.ContainerName == "" {
|
if c.OsType != types.Ubuntu && c.OsType != types.Flatpak && c.Command != "init" && c.ContainerName == "" {
|
||||||
cmd := exec.Command("/bin/bash", "-c", "apx subsystems list | grep ^" + c.ContainerSubsystem() + "$")
|
cmd := exec.Command("/bin/bash", "-c", "apx subsystems list")
|
||||||
cmd.Stdin = os.Stdin
|
var outb bytes.Buffer
|
||||||
|
cmd.Stdout = &outb
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
cmd.Stdout = os.Stdout
|
err := cmd.Run()
|
||||||
if err := cmd.Wait(); err != nil {
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
re := regexp.MustCompile("^" + c.ContainerSubsystem() + "$")
|
||||||
|
if re.MatchString(outb.String()) {
|
||||||
fmt.Println("Warning: Subsystem hasn't been pre-initialized, initializing...")
|
fmt.Println("Warning: Subsystem hasn't been pre-initialized, initializing...")
|
||||||
cmd_exec := exec.Command("/bin/bash", "-c", "apx subsystems new -n " + c.ContainerSubsystem() + " -s " + c.ApxSubsystem())
|
cmd_exec := exec.Command("/bin/bash", "-c", "apx subsystems new -n " + c.ContainerSubsystem() + " -s " + c.ApxSubsystem())
|
||||||
|
cmd_exec.Stdout = os.Stdout
|
||||||
cmd_exec.Stdin = os.Stdin
|
cmd_exec.Stdin = os.Stdin
|
||||||
cmd_exec.Stderr = os.Stderr
|
cmd_exec.Stderr = os.Stderr
|
||||||
cmd_exec.Stdout = os.Stdout
|
|
||||||
if err := cmd_exec.Run(); err != nil {
|
if err := cmd_exec.Run(); err != nil {
|
||||||
fmt.Println("Apx Error: ", err)
|
fmt.Println("Apx Error: ", err)
|
||||||
return err
|
return err
|
||||||
@ -95,11 +103,16 @@ func (c *Command) processCommand() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if c.OsType != types.Ubuntu && c.OsType != types.Flatpak && c.Command != "init" && c.ContainerName != "" {
|
if c.OsType != types.Ubuntu && c.OsType != types.Flatpak && c.Command != "init" && c.ContainerName != "" {
|
||||||
cmd := exec.Command("/bin/bash", "-c", "apx subsystems list | grep ^" + c.ContainerName + "$")
|
cmd := exec.Command("/bin/bash", "-c", "apx subsystems list")
|
||||||
cmd.Stdin = os.Stdin
|
var outb bytes.Buffer
|
||||||
|
cmd.Stdout = &outb
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
cmd.Stdout = os.Stdout
|
err := cmd.Run()
|
||||||
if err := cmd.Wait(); err != nil {
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
re := regexp.MustCompile("^" + c.ContainerName + "$")
|
||||||
|
if re.MatchString(outb.String()) {
|
||||||
fmt.Println("Warning: Subsystem hasn't been pre-initialized, initializing...")
|
fmt.Println("Warning: Subsystem hasn't been pre-initialized, initializing...")
|
||||||
cmd_exec := exec.Command("/bin/bash", "-c", "apx subsystems new -n " + c.ContainerName + " -s " + c.ApxSubsystem())
|
cmd_exec := exec.Command("/bin/bash", "-c", "apx subsystems new -n " + c.ContainerName + " -s " + c.ApxSubsystem())
|
||||||
cmd_exec.Stdin = os.Stdin
|
cmd_exec.Stdin = os.Stdin
|
||||||
|
Loading…
Reference in New Issue
Block a user