mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-22 16:48:23 +01:00
send initpk.env in remotestate
This commit is contained in:
parent
9d150dc7e3
commit
525fe77a5f
@ -68,7 +68,7 @@ var ValidCommands = []string{
|
||||
"/comment",
|
||||
"/cd",
|
||||
"/compgen",
|
||||
"/setenv",
|
||||
"/setenv", "/unset",
|
||||
}
|
||||
|
||||
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":
|
||||
return SetEnvCommand(ctx, pk)
|
||||
|
||||
case "unset":
|
||||
return UnSetCommand(ctx, pk)
|
||||
|
||||
default:
|
||||
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 ") {
|
||||
metaCmd = "setenv"
|
||||
commandStr = strings.TrimSpace(commandStr[6:])
|
||||
} else if commandStr == "unset" || strings.HasPrefix(commandStr, "unset ") {
|
||||
metaCmd = "unset"
|
||||
commandStr = strings.TrimSpace(commandStr[5:])
|
||||
} else if commandStr[0] == '/' {
|
||||
spaceIdx := strings.Index(commandStr, " ")
|
||||
if spaceIdx == -1 {
|
||||
@ -437,6 +443,10 @@ func ScreenCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (sstor
|
||||
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) {
|
||||
return nil, nil
|
||||
}
|
||||
|
@ -115,6 +115,42 @@ func GetRemoteById(remoteId string) *MShellProc {
|
||||
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 {
|
||||
GlobalStore.Lock.Lock()
|
||||
defer GlobalStore.Lock.Unlock()
|
||||
@ -146,7 +182,10 @@ func GetAllRemoteState() []RemoteState {
|
||||
vars["status"] = proc.Status
|
||||
vars["type"] = proc.Remote.RemoteType
|
||||
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["remoteuser"] = proc.ServerProc.InitPk.User
|
||||
vars["remotehost"] = proc.ServerProc.InitPk.HostName
|
||||
|
@ -230,6 +230,7 @@ type HistoryItemType struct {
|
||||
|
||||
type RemoteState struct {
|
||||
Cwd string `json:"cwd"`
|
||||
Env []byte `json:"env"`
|
||||
}
|
||||
|
||||
func (s *RemoteState) Scan(val interface{}) error {
|
||||
|
Loading…
Reference in New Issue
Block a user