Ubuntu Suomen keskustelualueet

Ubuntun käyttö => Ohjelmointi, palvelimet ja muu edistyneempi käyttö => Aiheen aloitti: elohope - 11.07.22 - klo:14.45

Otsikko: Googlen Copilotin tekoäly yhden bash-skriptin testissä
Kirjoitti: elohope - 11.07.22 - klo:14.45
Heinäkuussa testejä tehdään rennosti ja vähän kieli poskella, ja raportoidaan tässä lomalukemiseksi.

Kirjauduttuani Githubin Copilotiin ja asennettuani koneelleni Visual Studio Coden ihmettelin tapahtunutta muutaman päivän. Tänään sain tekoälyltä apua, kun halusin kirjoittaa bash-skriptin, jolla tehdään matriisi kotikansion kansioista ja valitaan niistä musiikkikansio.

Copilot auttoi muotoilemaan ohjelman kuvauksen ja Ctrl + Enter käynnisti skriptin tuottamisen. Tässä tulos parin iteroinnin jälkeen.

Koodia: [Valitse]
#!/bin/bash


# bash script to select a music directory.

# Make an array of directories in home directory. Then, ask the user to select a directory with select construct.
# If the user selects a directory, then print the directory name and exit.
# If the user selects nothing, then print "No directory selected" and exit.

# Make an array of directories in home directory.
dirs=($(ls -d ~/*))

# Ask the user to select a directory with select construct.
select dir in "${dirs[@]}" "No directory selected"
do
# If the user selects a directory, then print the directory name and exit.
if [ "$dir" != "No directory selected" ]; then
echo $dir
exit 0
fi
done

# If the user selects nothing, then print "No directory selected" and exit.
echo "No directory selected"
exit 1

# End of select_music_directory.sh
# Path: select_music_directory.sh
#!/bin/bash

# bash script to select a music directory.

# Make an array of directories in home directory. Then, ask the user to select a directory with select construct.
# If the user selects a directory, then print the directory name and exit.
# If the user selects nothing, then print "No directory selected" and exit.

# Make an array of directories in home directory.
dirs=($(ls -d ~/Music/*))

# Ask the user to select a directory with select construct.
select dir in "${dirs[@]}" "No directory selected"
do
# If the user selects a directory, then print the directory name and exit.
if [ "$dir" != "No directory selected" ]; then
echo $dir
exit 0
fi
done

# If the user selects nothing, then print "No directory selected" and exit.
echo "No directory selected"
exit 1