MCPcopy Index your code
hub / github.com/coder/coder / showMOTD

Function showMOTD

agent/agentssh/agentssh.go:1317–1333  ·  view source on GitHub ↗

showMOTD will output the message of the day from the given filename to dest, if the file exists. https://github.com/openssh/openssh-portable/blob/25bd659cc72268f2858c5415740c442ee950049f/session.c#L784

(fs afero.Fs, dest io.Writer, filename string)

Source from the content-addressed store, hash-verified

1315//
1316// https://github.com/openssh/openssh-portable/blob/25bd659cc72268f2858c5415740c442ee950049f/session.c#L784
1317func showMOTD(fs afero.Fs, dest io.Writer, filename string) error {
1318 if filename == "" {
1319 return nil
1320 }
1321
1322 f, err := fs.Open(filename)
1323 if err != nil {
1324 if xerrors.Is(err, os.ErrNotExist) {
1325 // This is not an error, there simply isn't a MOTD to show.
1326 return nil
1327 }
1328 return xerrors.Errorf("open MOTD: %w", err)
1329 }
1330 defer f.Close()
1331
1332 return writeWithCarriageReturn(f, dest)
1333}
1334
1335// writeWithCarriageReturn writes each line with a carriage return to ensure
1336// that each line starts at the beginning of the terminal.

Callers 1

startPTYSessionMethod · 0.85

Calls 5

writeWithCarriageReturnFunction · 0.85
CloseMethod · 0.65
OpenMethod · 0.45
IsMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected