Skip to content

Commit

Permalink
fix (manpages) : Use export command instead of setting environment va…
Browse files Browse the repository at this point in the history
…riable

Signed-off-by: Rohan Kumar <[email protected]>
  • Loading branch information
rohanKanojia committed Feb 20, 2025
1 parent c9d7cc9 commit 50bdb63
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
10 changes: 4 additions & 6 deletions pkg/crc/manpages/manpages_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package manpages
import (
"compress/gzip"
"fmt"
crcos "github.com/crc-org/crc/v2/pkg/os"
"io"
"os"
"path/filepath"
Expand All @@ -22,6 +23,7 @@ var (
osEnvGetter = os.Getenv
osEnvSetter = os.Setenv
ManPathEnvironmentVariable = "MANPATH"
commandRunner = crcos.NewLocalCommandRunner()
CrcManPageHeader = &doc.GenManHeader{
Title: "CRC",
Section: "1",
Expand Down Expand Up @@ -74,12 +76,8 @@ func GenerateManPages(manPageGenerator func(targetDir string) error, targetDir s
func appendToManPathEnvironmentVariable(folder string) error {
manPath := osEnvGetter(ManPathEnvironmentVariable)
if !manPathAlreadyContains(folder, manPath) {
if manPath == "" {
manPath = folder
} else {
manPath = fmt.Sprintf("%s%c%s", manPath, os.PathListSeparator, folder)
}
err := osEnvSetter(ManPathEnvironmentVariable, manPath)
command := fmt.Sprintf("export MANPATH=%s:$MANPATH", manPath)
_, _, err := commandRunner.Run(command)
if err != nil {
return err
}
Expand Down
5 changes: 0 additions & 5 deletions test/e2e/testsuite/testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -1091,11 +1091,6 @@ func EnsureCRCManPagesAvailability(expectedStatus string) error {
return fmt.Errorf("failed to get user home directory: %v", err)
}
manPageDir := filepath.Join(userHomeDir, ".local", "share", "man", "man1")

err = util.ExecuteCommand(fmt.Sprintf("export MANPATH=%s:$MANPATH", manPageDir))
if err != nil {
return fmt.Errorf("failed to export MANPATH: %v", err)
}
for _, manPage := range expectedManFileList {
manFile := filepath.Join(manPageDir, manPage)
manCommand := fmt.Sprintf("man -P cat %s", manFile)
Expand Down

0 comments on commit 50bdb63

Please sign in to comment.