mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-08 19:38:51 +01:00
send initpk.env in remotestate
This commit is contained in:
parent
9d150dc7e3
commit
525fe77a5f
@ -68,7 +68,7 @@ var ValidCommands = []string{
|
|||||||
"/comment",
|
"/comment",
|
||||||
"/cd",
|
"/cd",
|
||||||
"/compgen",
|
"/compgen",
|
||||||
"/setenv",
|
"/setenv", "/unset",
|
||||||
}
|
}
|
||||||
|
|
||||||
func HandleCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (sstore.UpdatePacket, error) {
|
func HandleCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (sstore.UpdatePacket, error) {
|
||||||
@ -100,6 +100,9 @@ func HandleCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (sstor
|
|||||||
case "setenv":
|
case "setenv":
|
||||||
return SetEnvCommand(ctx, pk)
|
return SetEnvCommand(ctx, pk)
|
||||||
|
|
||||||
|
case "unset":
|
||||||
|
return UnSetCommand(ctx, pk)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("invalid command '/%s', no handler", pk.MetaCmd)
|
return nil, fmt.Errorf("invalid command '/%s', no handler", pk.MetaCmd)
|
||||||
}
|
}
|
||||||
@ -350,6 +353,9 @@ func evalCommandInternal(ctx context.Context, pk *scpacket.FeCommandPacketType)
|
|||||||
} else if commandStr == "setenv" || strings.HasPrefix(commandStr, "setenv ") {
|
} else if commandStr == "setenv" || strings.HasPrefix(commandStr, "setenv ") {
|
||||||
metaCmd = "setenv"
|
metaCmd = "setenv"
|
||||||
commandStr = strings.TrimSpace(commandStr[6:])
|
commandStr = strings.TrimSpace(commandStr[6:])
|
||||||
|
} else if commandStr == "unset" || strings.HasPrefix(commandStr, "unset ") {
|
||||||
|
metaCmd = "unset"
|
||||||
|
commandStr = strings.TrimSpace(commandStr[5:])
|
||||||
} else if commandStr[0] == '/' {
|
} else if commandStr[0] == '/' {
|
||||||
spaceIdx := strings.Index(commandStr, " ")
|
spaceIdx := strings.Index(commandStr, " ")
|
||||||
if spaceIdx == -1 {
|
if spaceIdx == -1 {
|
||||||
@ -437,6 +443,10 @@ func ScreenCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (sstor
|
|||||||
return update, nil
|
return update, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func UnSetCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (sstore.UpdatePacket, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
func SetEnvCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (sstore.UpdatePacket, error) {
|
func SetEnvCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (sstore.UpdatePacket, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
@ -115,6 +115,42 @@ func GetRemoteById(remoteId string) *MShellProc {
|
|||||||
return GlobalStore.Map[remoteId]
|
return GlobalStore.Map[remoteId]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func unquoteDQBashString(str string) (string, bool) {
|
||||||
|
if len(str) < 2 {
|
||||||
|
return str, false
|
||||||
|
}
|
||||||
|
if str[0] != '"' || str[len(str)-1] != '"' {
|
||||||
|
return str, false
|
||||||
|
}
|
||||||
|
rtn := make([]byte, 0, len(str)-2)
|
||||||
|
for idx := 1; idx < len(str)-1; idx++ {
|
||||||
|
ch := str[idx]
|
||||||
|
if ch == '"' {
|
||||||
|
return str, false
|
||||||
|
}
|
||||||
|
if ch == '\\' {
|
||||||
|
if idx == len(str)-2 {
|
||||||
|
return str, false
|
||||||
|
}
|
||||||
|
nextCh := str[idx+1]
|
||||||
|
if nextCh == '\n' {
|
||||||
|
idx++
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if nextCh == '$' || nextCh == '"' || nextCh == '\\' || nextCh == '`' {
|
||||||
|
idx++
|
||||||
|
rtn = append(rtn, nextCh)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
rtn = append(rtn, '\\')
|
||||||
|
continue
|
||||||
|
} else {
|
||||||
|
rtn = append(rtn, ch)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return string(rtn), true
|
||||||
|
}
|
||||||
|
|
||||||
func GetAllRemoteState() []RemoteState {
|
func GetAllRemoteState() []RemoteState {
|
||||||
GlobalStore.Lock.Lock()
|
GlobalStore.Lock.Lock()
|
||||||
defer GlobalStore.Lock.Unlock()
|
defer GlobalStore.Lock.Unlock()
|
||||||
@ -146,7 +182,10 @@ func GetAllRemoteState() []RemoteState {
|
|||||||
vars["status"] = proc.Status
|
vars["status"] = proc.Status
|
||||||
vars["type"] = proc.Remote.RemoteType
|
vars["type"] = proc.Remote.RemoteType
|
||||||
if proc.ServerProc != nil && proc.ServerProc.InitPk != nil {
|
if proc.ServerProc != nil && proc.ServerProc.InitPk != nil {
|
||||||
state.DefaultState = &sstore.RemoteState{Cwd: proc.ServerProc.InitPk.HomeDir}
|
state.DefaultState = &sstore.RemoteState{
|
||||||
|
Cwd: proc.ServerProc.InitPk.Cwd,
|
||||||
|
Env: proc.ServerProc.InitPk.Env,
|
||||||
|
}
|
||||||
vars["home"] = proc.ServerProc.InitPk.HomeDir
|
vars["home"] = proc.ServerProc.InitPk.HomeDir
|
||||||
vars["remoteuser"] = proc.ServerProc.InitPk.User
|
vars["remoteuser"] = proc.ServerProc.InitPk.User
|
||||||
vars["remotehost"] = proc.ServerProc.InitPk.HostName
|
vars["remotehost"] = proc.ServerProc.InitPk.HostName
|
||||||
|
@ -230,6 +230,7 @@ type HistoryItemType struct {
|
|||||||
|
|
||||||
type RemoteState struct {
|
type RemoteState struct {
|
||||||
Cwd string `json:"cwd"`
|
Cwd string `json:"cwd"`
|
||||||
|
Env []byte `json:"env"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *RemoteState) Scan(val interface{}) error {
|
func (s *RemoteState) Scan(val interface{}) error {
|
||||||
|
Loading…
Reference in New Issue
Block a user